c#读取快递100查询返回的JSON信息

时间:2023-12-10 20:28:08

{"message":"ok","nu":"1105016801203","companytype":"ems","ischeck":"1","com":"ems","updatetime":"2014-08-01 10:17:31","status":"200","condition":"F00","codenumber":"1105016801203","data":[{"time":"2014-07-30 16:47:00","location":"","context":"赤峰市邮政速递物流分公司新华路揽投部 妥投 本人收签收","ftime":"2014-07-30 16:47:00"},{"time":"2014-07-30 15:18:00","location":"","context":"赤峰市邮政速递物流分公司新华路揽投部 安排投递","ftime":"2014-07-30 15:18:00"},{"time":"2014-07-30 15:09:30","location":"","context":"赤峰市邮政速递物流分公司新华路揽投部 到达处理中心,来自赤峰市","ftime":"2014-07-30 15:09:30"},{"time":"2014-07-30 12:03:42","location":"","context":"赤峰市 离开处理中心,发往赤峰市邮政速递物流分公司新华路揽投部","ftime":"2014-07-30 12:03:42"},{"time":"2014-07-30 11:23:49","location":"","context":"赤峰市 到达处理中心,来自上海市","ftime":"2014-07-30 11:23:49"},{"time":"2014-07-27 23:37:00","location":"","context":"上海市 离开处理中心,发往赤峰市","ftime":"2014-07-27 23:37:00"},{"time":"2014-07-27 15:46:16","location":"","context":"上海市邮政速递物流有限公司北临空揽投部 离开处理中心,发往上海市","ftime":"2014-07-27 15:46:16"},{"time":"2014-07-27 14:27:00","location":"","context":"上海市邮政速递物流有限公司北临空揽投部 收寄","ftime":"2014-07-27 14:27:00"}],"state":"3"}

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

            JObject jos = (JObject)JsonConvert.DeserializeObject(textBox1.Text);
string str = jos["data"].ToString();
JArray ja = (JArray)JsonConvert.DeserializeObject(str);
foreach (JObject o in ja)
{
textBox2.Text += o["context"] + "\r\n";
}