I have the following Json string
{ "Users" : [
{ "Name" : "user99",
"Value" : "test"
},
{ "Name" : "test2",
"Value" : "test"
}
]
}
I am trying to parse it and print out each name and value - what is the easiest way to do this ? I tried jQuery.parseJSON but I do not know how to use it I guess
Sample code would be great
var json = '{"Users":[{"Name":"user999","Value":"test"},{"Name":"test2","Value":"test"}]}';
var json_parsed = $.parseJSON(json);
for (var u = 0; u < json_parsed.Users.length; u++){
var user = json_parsed.Users[u];
$('body').append($('<p>').html('User: '+user.Name+'<br />Value: '+user.Value));
}
Results in:
<p>User: user999<br />Value: test</p>
<p>User: test2<br />Value: test</p>
jsFiddle Example: http://jsfiddle.net/bradchristie/XtzjZ/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With