0

I have a json object in the following format

{
    "class": "model",
    "valueDataArray": [
        "category": "supply",
        "const": "123"
    },
    {
        "category": "prod",
        "text": "specify"
    }
],
"LinkArray": [
    {
        "from": 1,
        "to": 2
    },
    {
        "from": 2,
        "to": 3
    }
]

how can i get the values in valueDataArray? please Help

4
  • 3
    your JSON looks invalid.! Commented Dec 31, 2013 at 12:37
  • 1
    @RajaprabhuAravindasamy - it is indeed invalid Commented Dec 31, 2013 at 12:38
  • 1
    hint... jsonlint.com You're missing a '{' in your first item of valueDataArray. Commented Dec 31, 2013 at 12:40
  • Invalid Data array , check and repost Commented Dec 31, 2013 at 12:44

3 Answers 3

3
data = JSON.parse(data);
alert(data.valueDataArray.category);
Sign up to request clarification or add additional context in comments.

Comments

3

I assume that you are using jquery then use

data = $.parseJSON(data);
alert(data.valueDataArray.category);

Comments

0

You can use native JSON.parse() method. Also your JSON need to be fixed. Here is a working example (with JSON fixed)

http://jsbin.com/AqIYOcIY/1/edit

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.