Deserialize array of key value pairs using Json.NET

前端 未结 4 1355
南笙
南笙 2020-12-03 13:51

Given the following json:

[ {\"id\":\"123\", ... \"data\":[{\"key1\":\"val1\"}, {\"key2\":\"val2\"}], ...}, ... ]

that is part of a bigger

4条回答
  •  悲哀的现实
    2020-12-03 14:16

    Thanks @Boo for your answer but in my case I needed to take some small adjustements. This is how my JSON looks like:

    {
        "rates": {
            "CAD": 1.5649,
            "CZK": 26,118,
            ...
        },
        "base": "EUR",
        "date": "2020-08-16"
    }
    

    And my DTO looks like the following:

    public IDictionary Rates { get; set; }
    public string Base { get; set; }
    public DateTime Date { get; set; }
    

    So the only adjustement was to remove the IEnumerable around the IDictionary.

提交回复
热议问题