C# 中对于json的解析小结
1、解析之前的json格式
[{
"Name": "冯111",
"PID": "130627199202283306",
"Jbyanglaobx": "100",
"Jbyiliaobx": "200",
"Sybx": "300",
"Zfgjj": "400",
"Nj": "500"
},
{
"Name": "冯333",
"PID": "130627199202283307",
"Jbyanglaobx": "200",
"Jbyiliaobx": "300",
"Sybx": "400",
"Zfgjj": "500",
"Nj": "600"
}
]
2、解析之后的json格式为
{
"whichPeriod": "201812",
"data": [{
"identificationNumber": "130627199202283306",
"name": "冯111",
"endowmentInsurance": "100",
"medicalinsurance": "200",
"insurancePremium": "300",
"housingFund": "400",
"annuity": "500"
},
{
"identificationNumber": "130627199202283307",
"name": "冯333",
"endowmentInsurance": "200",
"medicalinsurance": "300",
"insurancePremium": "400",
"housingFund": "500",
"annuity": "600"
}
]
}
方法为
private string parseJson(string para, string sbmonth)
{
JArray jarryOut = new JArray();
JObject json = new JObject();
json.Add("whichPeriod", sbmonth);
JArray jarry = (JArray)JsonConvert.DeserializeObject(para, GlobalInfo.GetInstance().jsonSetting);
for(int i=0; i