{
"data": {
"accountTypeCode": "2",
"accountTypeName": "123",
"address": "123123",
"birthdate": "1981-11-13",
"cardNo": "1231",
"cardTypeCode": "1",
"cardTypeName": "123123",
"contracts": [
{
"contractEnd": "2018-12-27",
"contractOrgCode": "A01",
"contractOrgName": "123123",
"contractStart": "2015-12-28",
"contractTypeCode": "1",
"contractTypeName": "123123"
}
],
"degreeCode": "4",
"degreeName": "12312",
"departmentCode": "A01A01A13A03",
"departmentID": "267",
"departmentName": "12312",
"deptCode": "A01A01A13A03",
"deptID": "267",
"deptName": "123123",
"domainAccount": "zhangxb03",
"econtact": "123213",
"econtactTel": "18202087959",
"edus": [
{
"eduCertificate": "123213",
"eduCollege": "12312",
"eduEnd": "2013-07-01",
"eduMajor": "123123",
"eduStart": "2009-09-01"
}
],
"email": "zhangxb03@haid.com.cn",
"employTypeCode": "1",
"employTypeName": "123213",
"familys": [
{
"familyAddress": "",
"familyName": "123213",
"familyPost": "",
"familyRelationship": "123",
"familyTel": "18202087959",
"familyWork": "无"
}
],
"genderCode": "0",
"genderName": "1231",
"graduateSchool": "12312",
"height": 167,
"hireDwDate": "2015-12-28",
"hireHdDate": "2015-12-28",
"hunyuStateCode": "2",
"hunyuStateName": "123",
"isReentryCode": "N",
"isReentryName": "否",
"jobTypeID": "2",
"jobTypeName": "123类",
"language": "",
"languageLevel": "",
"lineID": "1",
"lineName": "IT/1231线",
"major": "计算123123应用",
"name": "张1231",
"nationTypeCode": "1",
"nationTypeName": "汉族",
"nativePlace": "123省",
"nextPost": "",
"nowAddress": "123123",
"officeTel": "1",
"politicsCode": "0",
"politicsName": "其他",
"postID": "655",
"postName": "12312",
"rankCode": "12",
"rankName": "12级",
"rankRange": "C",
"regionCode": "A01A01",
"regionID": "2",
"regionName": "12321",
"relation": "123",
"remark": "",
"resumes": [
{
"resumeCertifier": "",
"resumeCertifierTel": "",
"resumeEnd": "2015-12-01",
"resumePost": "123123",
"resumeReason": "12312",
"resumeStart": "2012-10-01",
"resumeWorkUnit": "123"
}
],
"specialily": "",
"staffNo": "012836",
"statusCode": "1",
"statusName": "在职",
"subCode": "A01A01A13",
"subID": "43",
"subName": "123123",
"tel": "13760758282",
"title": "",
"weight": 70,
"workPlaceCode": "1",
"workPlaceName": "1231"
},
"msg": "获取数据成功",
"success": true
}
使用什么能获取到data里的数据集合,试了很多方法都不行,求大神指点
a = 你那一串
a[data]即可
这样也不可以
@XianBin_Zhang: 你用的什么语言?这明明是个字典,亲,怎么是列表了?
首先你要确认你的json是json对象吗。还就是一串字符串啊。
如果就是一串字符串的话,你先转成json对象,然后才能获取data的数据。
var json="你的那串字符串;;
var jp=Eval('('+json+')');
console.log(jp.data);
@XianBin_Zhang: 那就更简单了啊,你直接用Newtonsoft.json转成对象就行了啊。
想获取啥,直接用j点出来就来了。哪里需要点哪里。。。^_^
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; namespace ConsoleApp2 { class Program { static void Main(string[] args) { Rootobject j = JsonConvert.DeserializeObject<Rootobject>("你在那个串"); var data = j.data; } } public class Rootobject { public Data data { get; set; } public string msg { get; set; } public bool success { get; set; } } public class Data { public string accountTypeCode { get; set; } public string accountTypeName { get; set; } public string address { get; set; } public string birthdate { get; set; } public string cardNo { get; set; } public string cardTypeCode { get; set; } public string cardTypeName { get; set; } public Contract[] contracts { get; set; } public string degreeCode { get; set; } public string degreeName { get; set; } public string departmentCode { get; set; } public string departmentID { get; set; } public string departmentName { get; set; } public string deptCode { get; set; } public string deptID { get; set; } public string deptName { get; set; } public string domainAccount { get; set; } public string econtact { get; set; } public string econtactTel { get; set; } public Edu[] edus { get; set; } public string email { get; set; } public string employTypeCode { get; set; } public string employTypeName { get; set; } public Family[] familys { get; set; } public string genderCode { get; set; } public string genderName { get; set; } public string graduateSchool { get; set; } public int height { get; set; } public string hireDwDate { get; set; } public string hireHdDate { get; set; } public string hunyuStateCode { get; set; } public string hunyuStateName { get; set; } public string isReentryCode { get; set; } public string isReentryName { get; set; } public string jobTypeID { get; set; } public string jobTypeName { get; set; } public string language { get; set; } public string languageLevel { get; set; } public string lineID { get; set; } public string lineName { get; set; } public string major { get; set; } public string name { get; set; } public string nationTypeCode { get; set; } public string nationTypeName { get; set; } public string nativePlace { get; set; } public string nextPost { get; set; } public string nowAddress { get; set; } public string officeTel { get; set; } public string politicsCode { get; set; } public string politicsName { get; set; } public string postID { get; set; } public string postName { get; set; } public string rankCode { get; set; } public string rankName { get; set; } public string rankRange { get; set; } public string regionCode { get; set; } public string regionID { get; set; } public string regionName { get; set; } public string relation { get; set; } public string remark { get; set; } public Resume[] resumes { get; set; } public string specialily { get; set; } public string staffNo { get; set; } public string statusCode { get; set; } public string statusName { get; set; } public string subCode { get; set; } public string subID { get; set; } public string subName { get; set; } public string tel { get; set; } public string title { get; set; } public int weight { get; set; } public string workPlaceCode { get; set; } public string workPlaceName { get; set; } } public class Contract { public string contractEnd { get; set; } public string contractOrgCode { get; set; } public string contractOrgName { get; set; } public string contractStart { get; set; } public string contractTypeCode { get; set; } public string contractTypeName { get; set; } } public class Edu { public string eduCertificate { get; set; } public string eduCollege { get; set; } public string eduEnd { get; set; } public string eduMajor { get; set; } public string eduStart { get; set; } } public class Family { public string familyAddress { get; set; } public string familyName { get; set; } public string familyPost { get; set; } public string familyRelationship { get; set; } public string familyTel { get; set; } public string familyWork { get; set; } } public class Resume { public string resumeCertifier { get; set; } public string resumeCertifierTel { get; set; } public string resumeEnd { get; set; } public string resumePost { get; set; } public string resumeReason { get; set; } public string resumeStart { get; set; } public string resumeWorkUnit { get; set; } } }
@XianBin_Zhang:
说了需要什么,直接就获取了啊。。、
static void Main(string[] args) { Rootobject j = JsonConvert.DeserializeObject<Rootobject>("你在那个串"); var contracts = j.data.contracts; var resumes = j.data.resumes; var familys = j.data.familys; var edus = j.data.edus; }
代码都给你了,还不知道怎么搞真无语了。
@XianBin_Zhang:
估计是是这个初学者吧,都给你吧。你说的数组。如果获取里面的值要循环。。。
static void Main(string[] args) { Rootobject j = JsonConvert.DeserializeObject<Rootobject>("你在那个串"); var contracts = j.data.contracts; var resumes = j.data.resumes; var familys = j.data.familys; foreach (var item in familys) { var ad = item.familyAddress; } var edus = j.data.edus; }
@XianBin_Zhang: 我..........
楼上的吧代码都写好给你了,如果还不会,只能找个人手把手教你如何读代码了