Nearly 24 hours of my life lost and I just figured this out. Maybe I can save someone else some precious time.
Overview of JSON (skip this if you know what JSON is)
I was struggling with certain entries in the database that returned “NULL”. Some worked, some returned NULL. What’s that about?
After looking into it I discovered that the character sets chosen are messing up JSON. In other words, odd HTML characters or encoded characters were getting lost in the JSON encoding and just being dropped. Every “solution” nearly solved my problem but left another issue remaining. I tried stripping slashes, encoding html_special_chars, decoding them, etc.
The only way I found to solve the problem was when inserting the data into the database. Simply convert the text using PHP’s utf8_encode() function, and voila!
$text = utf8_encode($text);
Insert the converted text and all is well.