程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> json-C#,沒有key只有value的JSON串,如何轉換為list<T>

json-C#,沒有key只有value的JSON串,如何轉換為list<T>

編輯:編程綜合問答
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}

最佳回答:


 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>");
        }
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved