2014-01-28 33 views
0

我有这个从Web服务的JSON输出。如何将这个JSON加载到C#中的List对象?

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

如何使用Newton Soft JSON库将其加载到如下所示的列表中?

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

列出项目;

我是JSON的新手。

谢谢。

+0

得把JSON字符串和反序列化作为一个新的'Item'实例 – sircapsalot

回答

4

您的JSON是不是数组只是一个单一的对象

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

感谢L.B. !作品。 – user715993

相关问题