c#如何解析带有多层次list的json,直接上题如下: 5
求源码解析如下json串(brokerList存的对象类型是EmsBroker,其余字段均为string),微软自带的JavaScriptSerializer根本不行,一...
求源码解析如下json串(brokerList存的对象类型是EmsBroker,其余字段均为string),微软自带的JavaScriptSerializer根本不行,一解析只能知道有10个对象,其余所有字段都为空...求大神来,小菜别来
[{"brokerList":[],"category":"GRAVITY_UAT","env":"UAT","isChecked":"Y","state":""},{"brokerList":[],"category":"ML_CNTG","env":"UAT","isChecked":"Y","state":""},{"brokerList":[],"category":"ML_PROD","env":"UAT","isChecked":"Y","state":""},{"brokerList":[],"category":"ML_PROD_ROUTER","env":"UAT","isChecked":"Y","state":""},{"brokerList":[],"category":"ML_UAT","env":"UAT","isChecked":"Y","state":""},{"brokerList":[],"category":"RQ_UAT","env":"UAT","isChecked":"Y","state":""},{"brokerList":[],"category":"Vantage_UAT","env":"UAT","isChecked":"Y","state":""},{"brokerList":[],"category":"ML_QA","env":"QA","isChecked":"Y","state":""},{"brokerList":[],"category":"ML_UAT_Router","env":"QA","isChecked":"Y","state":""},{"brokerList":[],"category":"ML_DEV","env":"DEV","isChecked":"Y","state":""}] 展开
[{"brokerList":[],"category":"GRAVITY_UAT","env":"UAT","isChecked":"Y","state":""},{"brokerList":[],"category":"ML_CNTG","env":"UAT","isChecked":"Y","state":""},{"brokerList":[],"category":"ML_PROD","env":"UAT","isChecked":"Y","state":""},{"brokerList":[],"category":"ML_PROD_ROUTER","env":"UAT","isChecked":"Y","state":""},{"brokerList":[],"category":"ML_UAT","env":"UAT","isChecked":"Y","state":""},{"brokerList":[],"category":"RQ_UAT","env":"UAT","isChecked":"Y","state":""},{"brokerList":[],"category":"Vantage_UAT","env":"UAT","isChecked":"Y","state":""},{"brokerList":[],"category":"ML_QA","env":"QA","isChecked":"Y","state":""},{"brokerList":[],"category":"ML_UAT_Router","env":"QA","isChecked":"Y","state":""},{"brokerList":[],"category":"ML_DEV","env":"DEV","isChecked":"Y","state":""}] 展开
展开全部
您好,
如果你要是解析这个JSON字符串的话,jsonData类应该这样建:
public class jsonData
{
public List<priceData> buyOrder;
public List<priceData> sellOrder;
public List<tradeData> trade;
}
解析过程:
public static void Main(string[] args)
{
var json = @"{'buyOrder':[{'price':'4372.000000','amount':'0.737391'},{'price':'4370.000000','amount':'0.340686'}],'sellOrder':[{'price':'4372.500000','amount':'0.589376'},{'price':'4387.800000','amount':'0.425231'}],'trade':[{'price':'4372.500000','volume':'0.246803','time':'2014-01-02 15:02:20','type':'2'},{'price':'4388.000000','volume':'0.000505','time':'2014-01-02 14:56:17','type':'1'}]}";
var data = ScriptDeserialize(json);
}
public static jsonData ScriptDeserialize(string strJson)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize<jsonData>(strJson);
}
如果你要是解析这个JSON字符串的话,jsonData类应该这样建:
public class jsonData
{
public List<priceData> buyOrder;
public List<priceData> sellOrder;
public List<tradeData> trade;
}
解析过程:
public static void Main(string[] args)
{
var json = @"{'buyOrder':[{'price':'4372.000000','amount':'0.737391'},{'price':'4370.000000','amount':'0.340686'}],'sellOrder':[{'price':'4372.500000','amount':'0.589376'},{'price':'4387.800000','amount':'0.425231'}],'trade':[{'price':'4372.500000','volume':'0.246803','time':'2014-01-02 15:02:20','type':'2'},{'price':'4388.000000','volume':'0.000505','time':'2014-01-02 14:56:17','type':'1'}]}";
var data = ScriptDeserialize(json);
}
public static jsonData ScriptDeserialize(string strJson)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize<jsonData>(strJson);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询