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..

Blackbelt
158k31 gold badges308 silver badges310 bronze badges
asked May 8, 2013 at 6:26

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 );
});
answered May 8, 2013 at 6:30
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

answered May 8, 2013 at 6:33

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'])
});
});
answered May 8, 2013 at 6:35

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.