Deserialize JSON with dynamic objects

后端 未结 4 954
梦毁少年i
梦毁少年i 2020-12-11 02:41

I have a JSON object that comes with a long list of area codes. Unfortunately each area code is the object name on a list in the Data object. How do I create a class that wi

4条回答
  •  心在旅途
    2020-12-11 02:53

    your json is incorrect, but if you do correct it you can use a json-to-csharp tool like the one on http://json2csharp.com/ to generate your classes:

    public class __invalid_type__201
    {
        public string city { get; set; }
        public string state { get; set; }
    }
    
    public class Data
    {
        public __invalid_type__201 __invalid_name__201 { get; set; }
    }
    
    public class RootObject
    {
        public bool success { get; set; }
        public string message { get; set; }
        public Data data { get; set; }
    }
    

提交回复
热议问题