Created
February 14, 2011 18:58
-
-
Save jamesantrobus/826348 to your computer and use it in GitHub Desktop.
Info for Newtonsoft.Json - Issue 6 https://github.com/chrisntr/Newtonsoft.Json/issues#issue/6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using Newtonsoft.Json; | |
| namespace jittest | |
| { | |
| public class Test | |
| { | |
| public void SerializeDeserialiseTest() | |
| { | |
| Person person = new Person("james"); | |
| person.Pets.Add(new Pet("Rex", "Dog")); | |
| string json = JsonConvert.SerializeObject(person); | |
| //throws System.TypeInitializationException when ran on a device (Attempted JIT compile) | |
| Person deserialized = JsonConvert.DeserializeObject<Person>(json); | |
| } | |
| } | |
| public class Person | |
| { | |
| [MonoTouch.Foundation.Preserve] | |
| public Person() {} | |
| public Person(string name) | |
| { | |
| Name = name; | |
| Pets = new List<Pet>(); | |
| } | |
| public string Name; | |
| public List<Pet> Pets; | |
| } | |
| public class Pet | |
| { | |
| public Pet(string name, string type) | |
| { | |
| Name = name; | |
| Type = type; | |
| } | |
| public string Name {get;set;} | |
| public string Type {get;set;} | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment