public void Deserialize() { var personAsJson = File.ReadAllText("Person.json"); var person = JsonConvert.DeserializeObject <Person>(personAsJson); UsefulFunctions.WritePersonToConsole(person); }
public void Deserialize() { var serializer = new XmlSerializer(typeof(Person)); var person = (Person)serializer.Deserialize(File.OpenRead("Person.xml")); UsefulFunctions.WritePersonToConsole(person); }
public void Serialize() { var person = UsefulFunctions.CreateAPerson(); var personAsJson = JsonConvert.SerializeObject(person, Formatting.Indented); Console.Out.WriteLine(personAsJson); }
public void Serialize() { var person = UsefulFunctions.CreateAPerson(); var serializer = new XmlSerializer(typeof(Person)); var writer = new StringWriter(); serializer.Serialize(writer, person); Console.Out.WriteLine(writer.ToString()); }