views:

228

answers:

1

Hi Guys,

at the moment I'm parsing the string with eval()-method and it works fine, but want to parse it with the native JSON methods of a browser. Is there good way to parse the string with jquery.parseJSON() or with any other jQuery method to an array of javascript objects? The string looks like

[
    {
        "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
    }
]

build with net.sf.json.JSONArray of Java.

jquery.parseJSON() can just parse strings like {"Key":"Value","Key":"Value",....} I guess?

thx for your help!

+2  A: 

You have a typo. It is jQuery, not jquery. Capitalization is important.

jQuery.parseJSON()

or

$.parseJSON()

This is supposed to parse it into a json object.

Dale
sorry, my fault :) I wrote jQuery.parseJSON() in my code, but it throws an exception. I guess jQuery.parseJSON() can not parse an string like [{"Key":"Value","Key":"Value"},{"Key":"Value","Key":"Value"},{....}]
joo