Should i encode it differently?
I'd say yes. Obviously the string you receive from the database is not UTF-8 encoded. And that's the problem, because json_encode
Docs needs UTF-8 encoded strings. If they are invalid, it will return NULL
- because there was no valid data to encode.
You can verify this by checking for the last error with the json_last_error
Docs function.
So when you query data from your database, tell the database server that you expect UTF-8 encoded data by setting the database client encoding. Consult the documentation of the database client library you're using, it's documented there.
See as well json_encode() non utf-8 strings? which shows how you can re-encode the strings itself if you don't want to change the database client connection.