循环遍历 JSON 对象列表 [英] Loop through JSON object List

查看:50
本文介绍了循环遍历 JSON 对象列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从网络服务返回一个 List<> 作为 JSON 对象的 List.我正在尝试使用 for 循环遍历列表并从属性中获取值.这是返回 JSON 的示例:

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);
}

这应该怎么做?

推荐答案

今天遇到了同样的问题,你的话题帮助了我,所以这里有解决方案 ;)

had same problem today, Your topic helped me so here goes solution ;)

 alert(result.d[0].EmployeeTitle);

这篇关于循环遍历 JSON 对象列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆