Empty json_encode() output in php 7.1.x

If you have an empty json_encode() and don’t know what the hell just went wrong, then this piece of code is really helpful.

If you get an error saying invalid UTF-8 characters or something similar, then all you need to do is set the character set of your database to UTF-8 in the following way.