JSON 序列化 与反序列化

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Runtime.Serialization.Json;
using System.Text;
namespace JSONStudy
{
public class JsonSerializer
{
public static string JsonSerializerName(PersonName p)
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(PersonName));
MemoryStream ms = new MemoryStream();
ser.WriteObject(ms, p);
string JsonString = Encoding.UTF8.GetString(ms.ToArray());
return JsonString;

}
public static PersonName JsonDeSerializer(string JsonString)
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(PersonName));
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(JsonString));
PersonName p = (PersonName)ser.ReadObject(ms);
return p;
}


}
}

我又回来了,回到了技术最前线,
上一篇:梯度下降从放弃到入门


下一篇:解决eclipse里不能创建tomcat7.0的server