不知道有没有什么更简便的方法了,我是这样实现的,有的话还烦请告诉我一下哈。
原始结果:"{\"Person\":[{\"Role\":\"管理员\",\"Result\":\"hhh\"},{\"Role\":\"普通用户\",\"Result\":\"ggg\"}],\"Link\":{\"超链接\":\"http://XXX/XXX/页面.aspx\"}}"
1.定义实体类,存放要返回的数据。
public class RootInfo{
public List<BB> RoleInfo();
public string Link;
}
public class BB{
public string Role{get;set;}
public string Result{get;set;}
}
2.函数实现部分(返回结果为数组)
public List<RootInfo> GetData(){
string jsonText=HttpPost(url,params);//传入参数调用。HttpPost具体方法在上篇文章中
JObject j=JObject.Parse(jsonText);//转为对象
int index = j["Person"].Count();//数组中元素的个数
for (int n = 0