0

I need the basic Help , I have a json object in the following format

Data = {"line":"1",
        "column":"1"
        "response":[{"criteria":"starts","response":"358","field":"S"},
                {"criteria":"ends","response":"359","field":"H"}]}

I can get the Line and Column value as below

var obj = $.parseJSON(data);             
var line = obj['line'];
var column=obj['column'];

I have tried below format but i cannt get response value:

var res = new Array(obj['response']);
alert(res[0]['criteria']);

And

var jsonObject = $.parseJSON(obj['response']);
var innerArray = jsonObject['response'];
alert(innerArray[0].fieldvalue);

how can i get the values in obj['response'] ? Any one could help me to find the solution

5
  • Try console.log(obj); Commented Mar 18, 2014 at 8:30
  • Data.response or Data['response'] should be the array. Commented Mar 18, 2014 at 8:30
  • 1
    obj['response'][0] ?? Commented Mar 18, 2014 at 8:31
  • Can not try it here, but how about Data['response']['criteria'] Commented Mar 18, 2014 at 8:32
  • what's the result of obj.response[0]? Commented Mar 18, 2014 at 8:32

1 Answer 1

3

Why do you need to create a new array?

var res = new Array(obj['response']);
alert(res[0]['criteria']);

It is already converted to an array after you parse the JSON string, so this will work:

var res = obj['response'];
alert(res[0]['criteria']);
Sign up to request clarification or add additional context in comments.

Comments

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.