Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON.parse Error #1132: Invalid JSON parse input (Flex / Actionscript / PHP)

I am getting "Error #1132: Invalid JSON parse input" and cannot understand why.

My json is generated by php: json_encode($x). Output json if displayed in TextArea(flex) shows this:

{
   "title":"The Incredibles",
   "year":"2004",
   "type":"movie",
   "id":"9806",
   "imdb_id":"tt0317705",
   "rating":8.6,
   "tagline":"No gut, no glory",
   "overview":"Bob Parr has given up his superhero days to log in time as an insurance adjuster and raise his three children with his formerly heroic wife in suburbia. But when he receives a mysterious assignment, it\\'s time to get back into costume.",
   "runtime":115,
   "budget":92000000,
   "image":"http:\/\/cf2.imgobject.com\/t\/p\/w185\/jjAgMfj0TAPvdC8E5AqDm2BBeYz.jpg",
   "trailer":"rMfrFG_69zM"
}

I validated with several validators and all of them say it's valid json.

On the flex side I am trying to access json with this code:

JSON.parse(event.result.toString());

but get the error. Has anyone had this problem?

Edit 1:

It seems that the overview line is where the issue is but I dont understand why exactly since I used php json_encode which should escape things correctly...

like image 665
DominicM Avatar asked Apr 07 '26 16:04

DominicM


1 Answers

The escape sequence of \\' appears to terminate the JSON.

it\\'s should be it\'s if you want "it's".

Since this JSON uses " for strings, it could just be: it's.

JSON:

{
   "title":"The Incredibles",
   "year":"2004",
   "type":"movie",
   "id":"9806",
   "imdb_id":"tt0317705",
   "rating":8.6,
   "tagline":"No gut, no glory",
   "overview":"Bob Parr has given up his superhero days to log in time as an insurance adjuster and raise his three children with his formerly heroic wife in suburbia. But when he receives a mysterious assignment, it\'s time to get back into costume.",
   "runtime":115,
   "budget":92000000,
   "image":"http:\/\/cf2.imgobject.com\/t\/p\/w185\/jjAgMfj0TAPvdC8E5AqDm2BBeYz.jpg",
   "trailer":"rMfrFG_69zM"
}
like image 184
Jason Sturges Avatar answered Apr 09 '26 06:04

Jason Sturges



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!