Skip to main content
Following question owners comment, a bit more clarified the answer.
Source Link
ihsany
  • 1.1k
  • 13
  • 12

Here is a sample that works for me

List<AddressModel>//Deserialize the JSON string with the model
List<Root> myList = JsonConvert.DeserializeObject<List<AddressModel>>DeserializeObject<List<Root>>(strJSON);

foreach(Root rootObj in myList) {
    //access properties of the deserialized object
    Console.WriteLine(rootObj.Input.statecode);
}

Update: For your JSON, your model should be something like that;

public class Input
    {
        public int statecode { get; set; }
        public int citycode { get; set; }
        public string pincode { get; set; }
        public string addresdetails { get; set; }
    }

    public class Root
    {
        public Input input { get; set; }
        public List<object> output { get; set; }
    }

Here is a sample that works for me

List<AddressModel> myList = JsonConvert.DeserializeObject<List<AddressModel>>(strJSON);

Update: For your JSON, your model should be something like that;

public class Input
    {
        public int statecode { get; set; }
        public int citycode { get; set; }
        public string pincode { get; set; }
        public string addresdetails { get; set; }
    }

    public class Root
    {
        public Input input { get; set; }
        public List<object> output { get; set; }
    }

Here is a sample that works for me

//Deserialize the JSON string with the model
List<Root> myList = JsonConvert.DeserializeObject<List<Root>>(strJSON);

foreach(Root rootObj in myList) {
    //access properties of the deserialized object
    Console.WriteLine(rootObj.Input.statecode);
}

Update: For your JSON, your model should be something like that;

public class Input
    {
        public int statecode { get; set; }
        public int citycode { get; set; }
        public string pincode { get; set; }
        public string addresdetails { get; set; }
    }

    public class Root
    {
        public Input input { get; set; }
        public List<object> output { get; set; }
    }
When I double check your JSON string and your model, it looks like your model needs some modification regarding to your JSON string.
Source Link
ihsany
  • 1.1k
  • 13
  • 12

Here is a sample that works for me

List<AddressModel> myList = JsonConvert.DeserializeObject<List<AddressModel>>(strJSON);

Update: For your JSON, your model should be something like that;

public class Input
    {
        public int statecode { get; set; }
        public int citycode { get; set; }
        public string pincode { get; set; }
        public string addresdetails { get; set; }
    }

    public class Root
    {
        public Input input { get; set; }
        public List<object> output { get; set; }
    }

Here is a sample that works for me

List<AddressModel> myList = JsonConvert.DeserializeObject<List<AddressModel>>(strJSON);

Here is a sample that works for me

List<AddressModel> myList = JsonConvert.DeserializeObject<List<AddressModel>>(strJSON);

Update: For your JSON, your model should be something like that;

public class Input
    {
        public int statecode { get; set; }
        public int citycode { get; set; }
        public string pincode { get; set; }
        public string addresdetails { get; set; }
    }

    public class Root
    {
        public Input input { get; set; }
        public List<object> output { get; set; }
    }
Source Link
ihsany
  • 1.1k
  • 13
  • 12

Here is a sample that works for me

List<AddressModel> myList = JsonConvert.DeserializeObject<List<AddressModel>>(strJSON);