【发布时间】:2018-02-04 22:48:28
【问题描述】:
问题
嗨,请帮我将 Json 反序列化为 C# 字典,其中 KeyValuePair 的键 = 'symbol' 的值,而 'cur' 我不想反序列化。
我的 JSON
[
{
"cur": "BNT",
"symbol": "BNT/BTC",
"last": 0.00069999,
"high": 0.000725,
"low": 0.000631,
"volume": 11.83176914,
"vwap": 0.00066075,
"max_bid": 0.000725,
"min_ask": 0.000631,
"best_bid": 0.00062001,
"best_ask": 0.0007
},
{
"cur": "FST",
"symbol": "FST/BTC",
"last": 0.00000113,
"high": 0.00000136,
"low": 0.0000011,
"volume": 105727.64821274,
"vwap": 0.00000115,
"max_bid": 0.0000012,
"min_ask": 0.00000108,
"best_bid": 0.00000115,
"best_ask": 0.00000127
}
]
C#
public class SomeClass
{
Dictionary<string,Ticker> dictionary { get; set; }
}
public class Ticker
{
public decimal Last { get; set; }
public decimal High { get; set; }
public decimal Low { get; set; }
public decimal Volume { get; set; }
public decimal Vwap { get; set; }
public decimal MaxBid { get; set; }
public decimal MinAsk { get; set; }
public decimal BestBid { get; set; }
public decimal BestAsk { get; set; }
}
我想我需要使用 CustomCreationConverter,但我不知道该怎么做 :)
谢谢
【问题讨论】:
-
您可能不需要自定义转换器。你确实需要阅读How to Ask,接受tour,做更多的研究并提出更清晰的问题
-
见:stackoverflow.com/questions/1207731/… Dastun 在这个帖子中的回答就是你所需要的。
标签: c# json dictionary