这个 JSON 有什么问题?

发布于 2025-01-03 18:38:08 字数 450 浏览 1 评论 0原文

我使用 json simple 来创建和解析一些 json。但是,在创建它之后,当我执行 parser.parse(jStr); 时,我会得到一个 ParseException 。下面是jStr的值,

{"score":12,"balls":[[PURPLE_V,134.33325,331.11713,2.0,10.750022,-115,11.0,0],[PURPLE_SPLAT,59.209473,169.87143,0.0,6.2909174,16,11.0,1],[GREEN_V,119.00015,73.71671,-12.0,6.7500067,-35,11.0,0],[ORANGE_V,229.66664,7.4416676,8.0,5.250001,-5,11.0,0]]}

这有什么问题吗?我可以不做数组的数组吗?

I'm using json simple to create and parse some json. However, after creating it, I then get a ParseException when I do parser.parse(jStr);. Below is the value of jStr

{"score":12,"balls":[[PURPLE_V,134.33325,331.11713,2.0,10.750022,-115,11.0,0],[PURPLE_SPLAT,59.209473,169.87143,0.0,6.2909174,16,11.0,1],[GREEN_V,119.00015,73.71671,-12.0,6.7500067,-35,11.0,0],[ORANGE_V,229.66664,7.4416676,8.0,5.250001,-5,11.0,0]]}

What's wrong with this? Can I not do an array of arrays?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

月牙弯弯 2025-01-10 18:38:08

PURPLE_VPURPLE_SPLATGREEN_VORANGE_V 应在引号内。

PURPLE_V, PURPLE_SPLAT,GREEN_V, ORANGE_V should be inside quotes.

南城旧梦 2025-01-10 18:38:08

尝试 JSONLint

{
    "score": 12,
    "balls": [
        [
            PURPLE_V,
            134.33325,
    // ..

输出

Parse error on line 4:
...      [            PURPLE_V,          
----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', ']'

PURPLE_V等不是可识别的类型。 如果您希望它们是字符串,请用引号将它们引起来。

Try JSONLint:

{
    "score": 12,
    "balls": [
        [
            PURPLE_V,
            134.33325,
    // ..

output

Parse error on line 4:
...      [            PURPLE_V,          
----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', ']'

PURPLE_V, etc. are not recognized types. If you wanted them to be Strings, surround 'em with quotes.

懷念過去 2025-01-10 18:38:08

非数字值应放在引号之间。

{"score":12,"balls":[["PURPLE_V",134.33325,331.11713,2.0,10.750022,-115,11.0,0],["PURPLE_SPLAT",59.209473,169.87143,0.0,6.2909174,16,11.0,1],["GREEN_V",119.00015,73.71671,-12.0,6.7500067,-35,11.0,0],["ORANGE_V",229.66664,7.4416676,8.0,5.250001,-5,11.0,0]]}

我建议您使用 http://jsonlint.com/ 来验证您的 JSON。您可能还想检查 http://www.json.org/

The non-numeric values should be between quotation marks.

{"score":12,"balls":[["PURPLE_V",134.33325,331.11713,2.0,10.750022,-115,11.0,0],["PURPLE_SPLAT",59.209473,169.87143,0.0,6.2909174,16,11.0,1],["GREEN_V",119.00015,73.71671,-12.0,6.7500067,-35,11.0,0],["ORANGE_V",229.66664,7.4416676,8.0,5.250001,-5,11.0,0]]}

I recommend you to use http://jsonlint.com/ to validate your JSON. You might also want to check http://www.json.org/

烂柯人 2025-01-10 18:38:08

更正(还有一些查看格式):

{"score":12,"balls":[
    ["PURPLE_V",134.33325,331.11713,2.0,10.750022,-115,11.0,0],
    ["PURPLE_SPLAT",59.209473,169.87143,0.0,6.2909174,16,11.0,1],
    ["GREEN_V",119.00015,73.71671,-12.0,6.7500067,-35,11.0,0],
    ["ORANGE_V",229.66664,7.4416676,8.0,5.250001,-5,11.0,0]
]}

请参阅 http://json.org

Corrected (with also some formatting for viewing):

{"score":12,"balls":[
    ["PURPLE_V",134.33325,331.11713,2.0,10.750022,-115,11.0,0],
    ["PURPLE_SPLAT",59.209473,169.87143,0.0,6.2909174,16,11.0,1],
    ["GREEN_V",119.00015,73.71671,-12.0,6.7500067,-35,11.0,0],
    ["ORANGE_V",229.66664,7.4416676,8.0,5.250001,-5,11.0,0]
]}

See http://json.org

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