using System; using System.Web.Script.Serialization;
namespaceJavaScriptDeserialize { classPerson { publicstring Name { get; set; }
} classProgram { staticvoidMain(string[] args) { // no SimpleTypeResolver Person person = new Person() { Name = "jack" }; JavaScriptSerializer serializer = new JavaScriptSerializer(); string v = serializer.Serialize(person); Console.WriteLine(v); Person p = serializer.Deserialize<Person>(v); Console.WriteLine(p.Name);
{"Name":"jack"} jack {"__type":"JavaScriptDeserialize.Person, ConsoleApplication2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","Name":"jack"} jack