Example #1
0
    void Start()
    {
        ExampleSerializedClass serializedClass = new ExampleSerializedClass();

        JsonWriter writer = new JsonWriter();

        writer.PrettyPrint = true;

        JsonMapper.ToJson(serializedClass, writer);

        string json = writer.ToString();

        Debug.Log(json);

        // If you don't need a JsonWriter, use this.
        //string json = JsonMapper.ToJson(exampleClass);

        ExampleSerializedClass deserializedClass = JsonMapper.ToObject <ExampleSerializedClass>(savedJsonString);

        Debug.Log(deserializedClass.myString);
    }
Example #2
0
    void Start()
    {
        ExampleSerializedClass serializedClass = new ExampleSerializedClass();

        JsonWriter writer = new JsonWriter();
        writer.PrettyPrint = true;

        JsonMapper.ToJson(serializedClass,writer);

        string json = writer.ToString();
        Debug.Log(json);

        // If you don't need a JsonWriter, use this.
        //string json = JsonMapper.ToJson(exampleClass);

        ExampleSerializedClass deserializedClass = JsonMapper.ToObject<ExampleSerializedClass>(savedJsonString);

        Debug.Log(deserializedClass.myString);
    }