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":""}]
展开
 我来答
山水阿锐
2015-05-09 · TA获得超过34.3万个赞
知道顶级答主
回答量:23.7万
采纳率:91%
帮助的人:3.2亿
展开全部
您好,
如果你要是解析这个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);

}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式