Example #1
0
 public bool Equals(TestObject7 other)
 {
     if (this.test_arr.Length != other.test_arr.Length)
     {
         Debug.LogWarning("TestObject7 : Lengths of test_arr does not match. Type TestObject6[]");
         return(false);
     }
     for (int i = 0; i < this.test_arr.Length; i++)
     {
         if (!this.test_arr[i].Equals(other.test_arr[i]))
         {
             Debug.LogWarning(String.Format("TestObject7 : Field test_arr[{0}] does not match. Type TestObject6[]", i));
             return(false);
         }
     }
     return(true);
 }
Example #2
0
    void Test7()
    {
        string      jsonString     = "{\"test_arr\":[{\"nested\":{\"nested_arr\":[{\"name\":\"vic\",\"id\":0},{\"name\":\"yuan\",\"id\":1000}],\"nested_test\":{\"nesteds\":[{\"name\":\"vic\",\"id\":0},{\"name\":\"yuan\",\"id\":1000},{\"name\":\"pepe\",\"id\":-30}]}}},{\"nested\":{\"nested_arr\":[{\"name\":\"vic\",\"id\":0},{\"name\":\"yuan\",\"id\":1000}],\"nested_test\":{\"nesteds\":[{\"name\":\"vic\",\"id\":0},{\"name\":\"yuan\",\"id\":1000},{\"name\":\"pepe\",\"id\":-30}]}}}]}";
        TestObject7 expectedResult = new TestObject7(new TestObject6[] {
            new TestObject6(new NestedObject2(
                                new NestedObject[] { new NestedObject("vic", 0), new NestedObject("yuan", 1000) },
                                new TestObject5(new NestedObject[] { new NestedObject("vic", 0), new NestedObject("yuan", 1000), new NestedObject("pepe", -30) })
                                )),
            new TestObject6(new NestedObject2(
                                new NestedObject[] { new NestedObject("vic", 0), new NestedObject("yuan", 1000) },
                                new TestObject5(new NestedObject[] { new NestedObject("vic", 0), new NestedObject("yuan", 1000), new NestedObject("pepe", -30) })
                                ))
        });

        TestObject7 obj = JsonParser.FromJson <TestObject7>(jsonString);

        if (expectedResult.Equals(obj))
        {
            Debug.Log("Reader Test 7 : Success");
        }
        else
        {
            Debug.LogWarning("Reader Test 7 : Failure");
        }

        string json = JsonParser.ToJson <TestObject7>(obj);

        if (jsonString == json)
        {
            Debug.Log("Writer Test 7 : Success");
        }
        else
        {
            Debug.LogWarning(String.Format("Writer Test 7 : Failure : {0}", json));
        }
    }