Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/459.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用jquery.parseJSON()解析JavaJSONArray_Java_Javascript_Jquery_Json - Fatal编程技术网

使用jquery.parseJSON()解析JavaJSONArray

使用jquery.parseJSON()解析JavaJSONArray,java,javascript,jquery,json,Java,Javascript,Jquery,Json,目前,我正在使用eval()-method解析字符串,它可以正常工作,但我希望使用浏览器的原生JSON方法解析它。有没有好方法可以使用jquery.parseJSON()或任何其他jquery方法将字符串解析为javascript对象数组?绳子看起来像 [ { "title": "01 Books", "groupId": "01", "groupName": "Books", "key": "1", "i

目前,我正在使用eval()-method解析字符串,它可以正常工作,但我希望使用浏览器的原生JSON方法解析它。有没有好方法可以使用jquery.parseJSON()或任何其他jquery方法将字符串解析为javascript对象数组?绳子看起来像

[
    {
        "title": "01  Books",
        "groupId": "01",
        "groupName": "Books",
        "key": "1",
        "isFolder": true,
        "expand": false,
        "isLazy": true
    },
    {
        "title": "02  Music",
        "groupId": "02",
        "groupName": "Music",
        "key": "2",
        "isFolder": true,
        "expand": false,
        "isLazy": true
    }
]
使用Java的net.sf.json.JSONArray构建

parseJSON()可以只解析像{“Key”:“Value”,“Key”:“Value”,…}这样的字符串


谢谢你的帮助

你有一个打字错误。它是jQuery,而不是jQuery。资本化很重要

jQuery.parseJSON()


这应该将其解析为json对象。

您有一个输入错误。它是jQuery,而不是jQuery。资本化很重要

jQuery.parseJSON()


这应该是将其解析为json对象。

只要它是有效的json,它就会解析它。.我尝试了jsonlint.com,结果它是有效的。我猜解析嵌套数组有问题吗?只要它是有效的json,它就会解析它..我尝试了jsonlint.com,结果它是有效的。我猜解析嵌套数组有问题吗?对不起,是我的错:)我在代码中编写了jQuery.parseJSON(),但它引发了一个异常。我猜jQuery.parseJSON()不能解析像[{“Key”:“Value”,“Key”:“Value”},{“Key”:“Value”,“Key”:“Value”},{…}]@joo这样的字符串。我用过jQuery.parseJSON(result)&结果是
code
{“resort0”:“船港阿巴科海滩度假村”,“resort1”:“亚历山大度假村”,“room0”:“1卧室豪华海滨套房”,“room1”:“两居室豪华海景套房”、“房间2”:“豪华花园景工作室”、“房间3”:“豪华海景工作室”、“房间4”:“豪华海滨”、“房间5”:“海滨”、“房间6”:“高级海滨”}
code
效果良好抱歉,我的错:)我在代码中编写了jQuery.parseJSON(),但它引发了一个异常。我猜jQuery.parseJSON()无法解析像[{“Key”:“Value”,“Key”:“Value”},{“Key”:“Value”,“Key”:“Value”},{…}]@joo这样的字符串。我使用了jQuery.parseJSON(result)&结果是
code
{“Restor0”:“船港阿巴科海滩度假村”,“Restor1”:“Alexandra度假村”,“room0”:“1卧室豪华海滨套房”,“room1”:“2卧室豪华海景套房”,“room2”:豪华园景工作室,“3号房间”:“豪华海景工作室”,“4号房间”:“豪华海滨”,“5号房间”:“海滨”,“6号房间”:“高级海滨”}
code
效果良好