How can I parse a JSON string that would cause illegal C# identifiers?

后端 未结 3 2288
孤城傲影
孤城傲影 2020-11-21 05:24

I have been using NewtonSoft JSON Convert library to parse and convert JSON string to C# objects. But now I have came across a really awkward JSON string and I am unable to

3条回答
  •  长情又很酷
    2020-11-21 05:54

    You can deserialize to a dictionary.

    public class Item
    {
        public string fajr { get; set; }
        public string sunrise { get; set; }
        public string zuhr { get; set; }
        public string asr { get; set; }
        public string maghrib { get; set; }
        public string isha { get; set; }
    }
    

    var dict = JsonConvert.DeserializeObject>(json);
    

提交回复
热议问题