求下面json字符串用JavaScriptSerializer反序列化代码..
求下面json字符串用JavaScriptSerializer反序列化代码..
[{brand:'android',model:['android2.0通用版','android1.6通用版','android1.5通用版','android2.1以上版']},{brand:'HTC',model:['HTC g12','HTC g11']}]
------解决方案--------------------你需要一个根据json格式生成的可序列化的实体类!
------解决方案--------------------C# code
public static T JsonDeserialize<T>(string jsonString)
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T));
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
T obj = (T)ser.ReadObject(ms);
return obj;
}