How can I deserialize a json string contianing a list and dictionary (or keyvalue) property objects

后端 未结 1 1997
心在旅途
心在旅途 2021-01-26 10:03

I want to create a C# object by parsing a Json string that contains embedded contianer objects. See StockHistory in the code snippet.

I tried defining the parent object

相关标签:
1条回答
  • 2021-01-26 10:10

    This might get you close:

    public class StockHistory
    {
        [JsonProperty("Meta Data")]
        public Dictionary<string, string> Meta_Data { get; set; }
        [JsonProperty("Time Series (5min)")]
        public Dictionary<string, LHOCV> Lhocv { get; set; }
    }
    
    public class LHOCV
    {
        [JsonProperty("3. low")]
        public float Low { get; set; }
        [JsonProperty("2. high")]
        public float High { get; set; }
        [JsonProperty("1. open")]
        public float Open { get; set; }
        [JsonProperty("4. close")]
        public float Close { get; set; }
        [JsonProperty("5. volume")]
        public double Volume { get; set; }
    }
    
    0 讨论(0)
提交回复
热议问题