JSON.parse 错误 #1132:无效的 JSON 解析输入 (Flex/Actionscript/PHP) [英] JSON.parse Error #1132: Invalid JSON parse input (Flex / Actionscript / PHP)

查看:27
本文介绍了JSON.parse 错误 #1132:无效的 JSON 解析输入 (Flex/Actionscript/PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误 #1132:无效的 JSON 解析输入"并且无法理解原因.

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

我的json是由php生成的:json_encode($x).如果显示在 TextArea(flex) 中,则输出 json 显示:

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"
}

我用几个验证器进行了验证,他们都说它是有效的 json.

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

在 flex 方面,我尝试使用以下代码访问 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?

编辑 1:

似乎概述行是问题所在,但我不明白为什么,因为我使用了应该正确转义的 php json_encode...

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

推荐答案

\\' 的转义序列似乎终止了 JSON.

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

it\\'s 应该是 it\'s 如果你想要it's".

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

由于这个 JSON 使用 " 作为字符串,它可能只是: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"
}

这篇关于JSON.parse 错误 #1132:无效的 JSON 解析输入 (Flex/Actionscript/PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆