问题描述
假设我用一个strings接受一个json值如下面的格式{"users":[{"real_name":"达坂城规","login_name":"dbc_gh","password":"361f5d35b6495c2d09918d88b7bdcf0f","organizationid":"10000952","organization":"达","userstatus":"1"},{"real_name":"gjfd_fzxm","login_name":"gjfd_fzxm","password":"b885cf03fa30a2198fcc90c8d0487f93","organizationid":"10000186","organization":"抚州","userstatus":"1"},]}我想批量获取里面的具体值比如获取每条数据的real_name的值,还有loging_name的值请问如何获取
解决方案
解决方案二:
设置实体对应json格式,然后反序列化后就是循环操作……
解决方案三:
1、定义实体类,用于接收json字符串反序列化publicclassUsers{publicstringreal_name{get;set;}publicstringlogin_name{get;set;}publicstringpassword{get;set;}publicstringorganizationid{get;set;}publicstringorganization{get;set;}publicstringuserstatus{get;set;}}publicclassRootObject{publicList<Users>users{get;set;}}
2、反序列化List<Users>listUsers=JsonConvert.DeserializeObject<List<Users>>(json字符串);