HTML5 中的 JSON 问题

发布于 2024-12-28 00:30:20 字数 1147 浏览 1 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

手心的海 2025-01-04 00:30:20

问题在于同源策略。感谢泉。
解决方案是将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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文