C#,没有key只有value的JSON串,如何转换为list<T>

[]里面的JSON没有key只有value

Infor:{"tradeCode":"5040010","mess":"成功","data":[["801","玉璜","2114-10-01","订单","5.29","3.91","100%","100%","0.15%","0.0%","香港","香

港","1.00","1","0","0","0.00","0.0","0.0","0.0"],["802","双龙玉璜","2114-10-01","订单","5.17","3.82","100%","100%","0.15%","0.0%","香港","香

港","1.00","1","0","0","0.00","0.0","0.0","0.0"],["803","龙凤玉佩","2114-10-14","订单","2.32","1.72","100%","100%","0.3%","0.0%","香港","香

港","0.01","1","0","0","0.00","0.0","0.0","0.0"],["805","古玉屏风","2114-11-11","订单","1.97","1.45","100%","100%","0.3%","0.0%","香港","香

港","0.01","1","0","0","0.00","0.0","0.0","0.0"],["806","古玉玉龙","2114-12-18","订单","2.64","1.95","100%","100%","0.3%","0.0%","香港","香

港","0.01","1","0","0","0.00","0.0","0.0","0.0"]],"sid":"M74W4OIDTICHQ9AUE3NLRVGG90KUHFHT","ver":"1.0.0","zip":"n","charset":"UTF-

8","encrypt":"0","cryptKey":null,"digest":"","packetNo":1,"packetCounts":1,"returned":false}

2个回答

 List<string>

对象,下面是居于Newtonsoft.Json.Net20.dll类库的

 using System;
using System.Collections.Generic;
using Newtonsoft.Json;
public class ClsInfor
{
    public string tradeCode, mess;//其他的属性。。自己加
    public List<List<string>> data;
}
public class MyJson { public ClsInfor infor;}
  string s="{ Infor: { \"tradeCode\": \"5040010\", \"mess\": \"成功\", \"data\": [[\"801\", \"玉璜\", \"2114-10-01\", \"订单\", \"5.29\", \"3.91\", \"100%\", \"100%\", \"0.15%\", \"0.0%\", \"香港\", \"香港\", \"1.00\", \"1\", \"0\", \"0\", \"0.00\", \"0.0\", \"0.0\", \"0.0\"], [\"802\", \"双龙玉璜\", \"2114-10-01\", \"订单\", \"5.17\", \"3.82\", \"100%\", \"100%\", \"0.15%\", \"0.0%\", \"香港\", \"香港\", \"1.00\", \"1\", \"0\", \"0\", \"0.00\", \"0.0\", \"0.0\", \"0.0\"], [\"803\", \"龙凤玉佩\", \"2114-10-14\", \"订单\", \"2.32\", \"1.72\", \"100%\", \"100%\", \"0.3%\", \"0.0%\", \"香港\", \"香港\", \"0.01\", \"1\", \"0\", \"0\", \"0.00\", \"0.0\", \"0.0\", \"0.0\"], [\"805\", \"古玉屏风\", \"2114-11-11\", \"订单\", \"1.97\", \"1.45\", \"100%\", \"100%\", \"0.3%\", \"0.0%\", \"香港\", \"香港\", \"0.01\", \"1\", \"0\", \"0\", \"0.00\", \"0.0\", \"0.0\", \"0.0\"], [\"806\", \"古玉玉龙\", \"2114-12-18\", \"订单\", \"2.64\", \"1.95\", \"100%\", \"100%\", \"0.3%\", \"0.0%\", \"香港\", \"香港\", \"0.01\", \"1\", \"0\", \"0\", \"0.00\", \"0.0\", \"0.0\", \"0.0\"]], \"sid\": \"M74W4OIDTICHQ9AUE3NLRVGG90KUHFHT\", \"ver\": \"1.0.0\", \"zip\": \"n\", \"charset\": \"UTF-8\", \"encrypt\": \"0\", \"cryptKey\": null, \"digest\": \"\", \"packetNo\": 1, \"packetCounts\": 1, \"returned\": false} }";
        MyJson o = JsonConvert.DeserializeObject(s,typeof(MyJson)) as MyJson;
        Response.Write(o == null); 
        ClsInfor infor = o.infor;
        Response.Write(infor.mess + "<BR>"); 
        foreach (List<string> list in infor.data)
        {
            Response.Write(string.Join(",", list.ToArray()) + "<br>");
        }

JSON里面有key的叫字典,没key的叫数组。
如果你非得在C#中统一成字典,可以考虑用下标 0,1,2... 做key。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问