I wrote an API for a friend's wordpress site that relies on the JSON API plugin to get a JSON feed of her recent posts. It worked flawlessly for months, but a few days ago, stopped working entirely just when her shared host made the switch over to PHP 5.3 (of course, they did not alert their users-- why should they?)
I dug around and found a strange error in the part of the code that takes a JSON string, and returns the decoded JSON object to another function. Previously, the code (which worked, I SWEAR!) worked like this:
$json_string = file_get_contents($url_to_json_string);
return json_decode($json_string);
This began to return NULL, and json_last_error was 4 (syntax error.) I checked the utf8_encoding: fine. I checked for BOM-strangeness (according to this post): fine. I validated the JSON string in jsonlint.com and in json.parser.online.fr and it was perfectly valid. No stray htmlentities, no wandering slashes. The JSON string itself was fine and should have validated.
Then, I changed the code to this:
$json_string = file_get_contents($url_to_json_string);
$json_object = json_decode($json_string);
return $json_object;
and it worked.
Does anyone know why this happened?