Monday, April 16, 2012

Loop through JSON object List

I am returning a List<> from a webservice as a List of JSON objects. I am trying to use a for loop to iterate through the list and grab the values out of the properties. This is a sample of the returning JSON:



{"d":[{"__type":"FluentWeb.DTO.EmployeeOrder",
"EmployeeName":"Janet Leverling",
"EmployeeTitle":"Sales Representative",
"RequiredDate":"\/Date(839224800000)\/",
"OrderedProducts":null}]}


So I am trying to extract the contents using something like this:



function PrintResults(result) {

for (var i = 0; i < result.length; i++) {
alert(result.employeename);
}


How should this be done?





No comments:

Post a Comment