0

I'm having the service response like,

{
    "Name": [
        [{
                "Key": "A",
                "Value": "Sample1"
            }
        ],
        [{
                "Key": "A",
                "Value": "Sample2"
            }
        ],
        [{
                "Key": "A",
                "Value": "Sample3"
            }
        ],
        [{
                "Key": "A",
                "Value": "Sample4"
            }
        ]
    ],
    "Title": "Office"
}

I need the output as Value field.

I tried lot of ways.But not getting any solutions. Please help me..

3 Answers 3

1

Try this:

var obj = {"Name":[[{"Key":"A","Value":"Sample1"}],[{"Key":"A","Value":"Sample2"}],[{"Key":"A","Value":"Sample3"}],[{"Key":"A","Value":"Sample4"}]],"Title":"Office"}

$.each( obj.Name, function( key, d ) {
  console.log( key + ": " + d[0].Value );
});
Sign up to request clarification or add additional context in comments.

Comments

1
var data= {"Name":[[{"Key":"A","Value":"Sample1"}],[{"Key":"A","Value":"Sample2"}],[{"Key":"A","Value":"Sample3"}],[{"Key":"A","Value":"Sample4"}]],"Title":"Office"};    
var output = [];

for(var i = 0;i<data.Name.length;i++) // data is your JSON response
    output.push(data.Name[i][0].Value);
alert(output);

Fiddle for your Reference

Comments

1

Please have a look on this jsfiddle http://jsfiddle.net/2dJAN/16/

var fields= {
    "Name": [
        [{
                "Key": "A",
                "Value": "Sample1"
            }
        ],
        [{
                "Key": "A",
                "Value": "Sample2"
            }
        ],
        [{
                "Key": "A",
                "Value": "Sample3"
            }
        ],
        [{
                "Key": "A",
                "Value": "Sample4"
            }
        ]
    ],
    "Title": "Office"
}

$.each(fields['Name'], function(index, value) {
$.each(value, function(index, innervalue) {
alert(innervalue['Value'])
});
});

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.