NET guy here, so i’m very rusty at Javascript (or JQuery for that matter)
I serialized a list from server side .NET that i need to access on the client side. The string result is in the following format.
[{"id":"1","name":"xxx"},{"id":"2","name":"yyy"}]
How do i iterate through this in Javascript? I’m having a hard time actually get the values in the array. I end up iterating through each character of the JSON string.
function BuildList() {
var result = '<%= JSON %>';
for (var obj in result) {
alert("Obj: " + obj);
for (var property in result[obj]) {
alert(property + "value: " + result[obj][property]);
}
}
}
Javascript has built in function to convert JSON to a javascript object, try this:
This code example was taken from here, where you can read a lot more about it.
With your example, it could be used like so:
Here is a working example