HTML5 中的 JSON 问题
我在 HTML5 上的 playN 1.0.3 中遇到 JSON 问题。 当我调用 JSON.parse(mystring)
并尝试解码下面的 json 文档时,出现此错误:
com.google.gwt.core.client.JavaScriptException: (SyntaxError): JSON.parse: unexpected end of data
注意:JSON.parse()
在 Java 模式下工作完美地串起来。此外,我使用 JSON 文档验证器 (JSONLint) 验证了 JSON 文档。
有人看到问题所在吗?也许数组或数组中的对象是问题所在,对吧? 也许是太长了?实际上,我的数组有 15 个对象,它们看起来与下面数组中的这三个对象类似。
{
"Array": [
{
"CorrectAnswer": "A",
"AnswerA": "A",
"AnswerD": "D",
"Artist": "Artist",
"AnswerB": "B",
"Title": "Title",
"AnswerC": "C"
},
{
"CorrectAnswer": "A",
"AnswerA": "A",
"AnswerD": "D",
"Artist": "Artist",
"AnswerB": "B",
"Title": "Title",
"AnswerC": "C"
},
{
"CorrectAnswer": "A",
"AnswerA": "A",
"AnswerD": "D",
"Artist": "Artist",
"AnswerB": "B",
"Title": "Title",
"AnswerC": "C"
}
]
}
I have problems with JSON in playN 1.0.3 on HTML5.
When I call JSON.parse(mystring)
and try to decode the json document below I get this error:
com.google.gwt.core.client.JavaScriptException: (SyntaxError): JSON.parse: unexpected end of data
Note: JSON.parse()
works in Java-Mode with this string perfectly. Moreover I validated the JSON-document using a JSON document validator (JSONLint).
Does anybody see the problem? Maybe the array or the objects in the array are the problem, right?
Maybe it's too long? In reality, my array has 15 objects, which look similar to these three objects in the array below.
{
"Array": [
{
"CorrectAnswer": "A",
"AnswerA": "A",
"AnswerD": "D",
"Artist": "Artist",
"AnswerB": "B",
"Title": "Title",
"AnswerC": "C"
},
{
"CorrectAnswer": "A",
"AnswerA": "A",
"AnswerD": "D",
"Artist": "Artist",
"AnswerB": "B",
"Title": "Title",
"AnswerC": "C"
},
{
"CorrectAnswer": "A",
"AnswerA": "A",
"AnswerD": "D",
"Artist": "Artist",
"AnswerB": "B",
"Title": "Title",
"AnswerC": "C"
}
]
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题在于同源策略。感谢泉。
解决方案是将PlayN-html的war部署到服务器
(请参阅PlayN 客户端与服务器的协作)
The problem is the same-orign-policy. Thanks to Quan.
The solution is to deploy the war of the PlayN-html to the server
(see Collaboration from PlayN client with server)