解析Json字符串我这边是使用了JObject的方法 需要引用一个类库

 

需要下载Newtonsoft.Json.rar dll

然后引用

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

 

第一个为解析字符串格式的Json

1 JObject jo = (JObject)JsonConvert.DeserializeObject(result);//result为要解析的字符串
2             string errcode = jo["errcode"].ToString();//[errcode]为解析字符串里面的字段 errcode为字段后面跟的值
3             string errmsg = jo["errmsg"].ToString();//同上
4             string recordresult = jo["recordresult"].ToString();//同上

第二个为解析字符串数组形式的Json

JArray jArray = (JArray)JsonConvert.DeserializeObject(recordresult);                string str = jArray[0]["checkType"].ToString();

本博客仅为自己记录使用不喜勿喷

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-08
  • 2021-05-26
  • 2021-11-19
猜你喜欢
  • 2022-01-08
  • 2022-02-05
  • 2022-12-23
  • 2021-12-06
  • 2021-05-30
  • 2021-10-06
相关资源
相似解决方案