[英]Deserialise JSON with variable names
I would like to deserialise a JSON file in C# so each order is on a seperate line with all values possible. 我想在C#中反序列化JSON文件,因此每个订单都在单独的一行上,所有可能的值都可以。 I don't have a problem with deserialising a JSON but this one has variable attribute names.
我对反序列化JSON没问题,但这具有可变的属性名称。 In example, the file below has 2 order: O1ZBIX-GGYTG-RJVXNK & ORJZUB-AL7JW-7BBWPZ.
例如,以下文件具有2个顺序:O1ZBIX-GGYTG-RJVXNK和ORJZUB-AL7JW-7BBWPZ。 Please advice how i can do this.
请建议我该怎么做。
{
"error": [],
"result": {
"open": {
"O1ZBIX-GGYTG-RJVXNK": {
"refid": null,
"userref": null,
"status": "open",
"opentm": 1486584202.2485,
"starttm": 0,
"expiretm": 0,
"descr": {
"pair": "XBTEUR",
"type": "sell",
"ordertype": "limit",
"price": "1019.000",
"price2": "0",
"leverage": "none",
"order": "sell 0.20809000 XBTEUR @ limit 1019.000"
},
"vol": "0.20809000",
"vol_exec": "0.00000000",
"cost": "0.00000",
"fee": "0.00000",
"price": "0.00000",
"misc": "",
"oflags": "fciq"
},
"ORJZUB-AL7JW-7BBWPZ": {
"refid": null,
"userref": null,
"status": "open",
"opentm": 1486468345.44,
"starttm": 0,
"expiretm": 0,
"descr": {
"pair": "LTCEUR",
"type": "sell",
"ordertype": "limit",
"price": "3.78000",
"price2": "0",
"leverage": "none",
"order": "sell 54.20054000 LTCEUR @ limit 3.78000"
},
"vol": "54.20054000",
"vol_exec": "0.00000000",
"cost": "0.00000",
"fee": "0.00000",
"price": "0.00000",
"misc": "",
"oflags": "fciq"
}
}
}
}
Install the latest version of Json.Net from http://www.newtonsoft.com/json 从http://www.newtonsoft.com/json安装最新版本的Json.Net
Then just use JObject o = JObject.Parse(json);
然后只需使用
JObject o = JObject.Parse(json);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.