The following JSON response returns null using json_decode()
Any ideas why it is invalid, and how can I make it valid to decode.
asked Dec 6, 2011 at 13:19
user137621
2 Answers 2
Look at http://jsonlint.com/
Accoring to JSONLint, you have the following error:
Parse error on line 82:
... "text": "Make it easier for
-----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
The error is with this in the string '\x27s'
The same again for line 92.
"Roger\x27scompanion\x3cem\x3ehelped\x3c/em\x3ehimwiththeren"
Replace them with their appropriate unicode characters or add an extra slash as one slash is escaping your string.
answered Dec 6, 2011 at 13:32
Flukey
6,5653 gold badges49 silver badges72 bronze badges
from PHP.net:
NULL is returned if the json cannot be decoded or if the encoded data is deeper than the recursion limit.
perhaps that is the issue?
1 Comment
KingCrunch
See above: "Any ideas why it is invalid". Exactly this is the question
lang-php
nullback? You can try cutting it in half, checking both halves. Then each quarter, etc.json_last_error()I gotint(4)which points toJSON_ERROR_SYNTAX Syntax error. Hope it helpsjson_last_error()now.