0

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
  • as long as it's valid json, it'll parse it.. Commented Jun 10, 2010 at 16:09
  • I tried jsonlint.com and there it's valid. I guess there is a problem to parse a nested array? Commented Jun 10, 2010 at 16:22

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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 i have used jQuery.parseJSON(result) & result is code {"resort0":"Abaco Beach Resort at Boat Harbour","resort1":"Alexandra Resort","room0":"1 Bedroom Luxury Oceanfront Suite","room1":"2 Bedroom Deluxe Ocean View Suite","room2":"Deluxe Garden View Studio","room3":"Deluxe Ocean View Studio","room4":"Deluxe Oceanfront","room5":"Oceanfront","room6":"Superior Oceanfront"} code and works fine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.