Last active
December 12, 2015 08:08
-
-
Save prime31/4741428 to your computer and use it in GitHub Desktop.
This file contains 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
// setup a semi-complex test object | |
var someObject = new SomeObject(); | |
someObject.anotherObject = new AnotherObject(); | |
someObject.anotherObjectList = new List<AnotherObject> | |
{ | |
new AnotherObject(), new AnotherObject(), new AnotherObject(), new AnotherObject() | |
}; | |
// serialize the class to json | |
var json = Json.jsonEncode( someObject ); | |
Debug.Log( json ); | |
// Test classes | |
public class SomeObject | |
{ | |
// fields | |
public string someString; | |
public int someInt; | |
public float someFloat; | |
public AnotherObject anotherObject; | |
public List<AnotherObject> anotherObjectList; | |
// props | |
public string stringProp { get; set; } | |
public int intProp { get; set; } | |
public float floatProp { get; set; } | |
protected string protectedStringPrivateGetProp { private get; set; } | |
private string privateStringProp { get; set; } | |
public SomeObject() | |
{ | |
var rand = new Random(); | |
someString = Utils.randomString( 10 ); | |
someInt = rand.Next(); | |
someFloat = rand.Next(); | |
stringProp = Utils.randomString( 15 ); | |
intProp = rand.Next(); | |
floatProp = rand.Next(); | |
privateStringProp = Utils.randomString( 5 ); | |
protectedStringPrivateGetProp = Utils.randomString( 15 ); | |
} | |
} | |
public class AnotherObject | |
{ | |
public float turd; | |
public string poopString; | |
public AnotherObject() | |
{ | |
turd = 3423.234f; | |
poopString = Utils.randomString( 10 ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is this "Json" library ? https://gist.github.com/darktable/1411710 ?