VS2008
引用System.ServiceModel.Web.dll
引用System.Runtime.Serialization.dll
private void Form1_Load(object sender, EventArgs e)
{
string _JsonText = "Json代码";
List<Test> _Test = new List<Test>();
DataContractJsonSerializer _Json = new DataContractJsonSerializer(_Test.GetType());
byte[] _Using = System.Text.Encoding.UTF8.GetBytes(_JsonText);
System.IO.MemoryStream _MemoryStream = new System.IO.MemoryStream(_Using);
_MemoryStream.Position = 0;
_Test =(List<Test>)_Json.ReadObject(_MemoryStream);
}
public class Test
{
public int cId = 0;
public string cName = "";
public int amount = 0;
public string price = "";
}
引用System.ServiceModel.Web.dll
引用System.Runtime.Serialization.dll
private void Form1_Load(object sender, EventArgs e)
{
string _JsonText = "Json代码";
List<Test> _Test = new List<Test>();
DataContractJsonSerializer _Json = new DataContractJsonSerializer(_Test.GetType());
byte[] _Using = System.Text.Encoding.UTF8.GetBytes(_JsonText);
System.IO.MemoryStream _MemoryStream = new System.IO.MemoryStream(_Using);
_MemoryStream.Position = 0;
_Test =(List<Test>)_Json.ReadObject(_MemoryStream);
}
public class Test
{
public int cId = 0;
public string cName = "";
public int amount = 0;
public string price = "";
}