反序列化一个object var str1 = "{id:1,name:'111',x:[1,2,3],y:{a:'ssss',b:'dddd'}"; var obj1 = JsonConvert.DeserializeAnonymousType(str1, new {id=1,name="1",x=new[]{1,2},y=new{a="1",b="b"}}); 反序列化一个数组 var str2 = "[{id:…
摘自:http://blog.csdn.net/cdefg198/article/details/7520398 using System.IO; using System.Web.Script.Serialization; using System.Runtime.Serialization.Json; public static List<T> JSONStringToList<T>(this string JsonStr) { JavaScriptSerializer Ser…
C#将对象序列化成JSON字符串 public string GetJsonString() { List<Product> products = new List<Product>(){ new Product(){Name="苹果",Price=5.5}, new Product(){Name="橘子",Price=2.5}, new Product(){Name="干柿子",Price=16.00} }; Produ…