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...

share|improve this question

it\\'s Should be it\'s if you want "it's". – Jason Sturges yesterday
feedback

1 Answer

up vote 0 down vote accepted

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"
}
share|improve this answer
I removed the php's addslashes() function so now it's just "it's" but like before I am getting "SyntaxError: Error #1132: Invalid JSON parse input." in flex. Code used: JSON.parse(event.result.toString())['title']. The reason for toString() is that it gives "1118: Implicit coercion of a value with static type Object to a possibly unrelated type String." otherwise. What am I missing? I tried hard coded var string with same json as above and it worked so I am guessing it has something to do with either toString() or the return type of "event.result" – DominicM yesterday
I marked it as correct answer as it does answer the question but I hope you can look into the problem in the comment, Thanks. – DominicM yesterday
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.