简体   繁体   中英

How to load this JSON into List Object in C#?

I have this JSON output from a web service.

{
  "address": "173.194.67.1",
  "country": "US",
  "stateprov": "California",
  "city": "Mountain View"
}

How Do I load it into a List typed as below using Newton Soft JSON library?

public class Item
    {
        public string address;
        public string country;
        public string stateprov;
        public string city;
    }

List items;

I am new to JSON.

thanks.

您的json不是数组,而只是单个对象

var item =  JsonConvert.DeserializeObject<Item>(yourjsonstring);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM