public void JsonCloneConvertableObject()
        {
            var myJsonObject = new MyJsonObject {
                Name = "testing"
            };

            var clonedObject = myJsonObject.JsonClone();

            Assert.IsFalse(ReferenceEquals(myJsonObject, clonedObject));
            Assert.AreEqual(myJsonObject.Name, clonedObject.Name);
        }
Beispiel #2
0
        public async Task <MyJsonObject> GetDeserializeObjectAsync(MyJsonObject cacheEntry, HttpResponseMessage httpResponseMessage)
        {
            var content = httpResponseMessage.Content;
            var data    = await content.ReadAsStringAsync();

            cacheEntry = JsonConvert.DeserializeObject <MyJsonObject>(data);

            ViewData["Data"] = "apiData";

            return(cacheEntry);
        }
        public MyJsonObject Get(string test)
        {
            MyJsonObject obj = new MyJsonObject()
            {
                mynumber  = 1234,
                myString1 = "Hello Matty",
                myString2 = "Hello Tester",
                myString3 = "Hello Vivi",
                myString4 = "Hello Leo",
                myString5 = "Hello Doft",
            };

            return(obj);
        }
Beispiel #4
0
    public void DoJsonExample()
    {
        MyJsonObject jsonObject = new MyJsonObject()
        {
            MyInteger         = 15,
            MyString          = "I am some string!",
            MyBoolean         = true,
            MyNestedReference = new MyJsonObject()
        };

        // With just one line of code it is converted to json!
        string json = JsonUtility.ToJson(jsonObject);

        Console.WriteLine(json);

        // And with another line of code it's converted back!
        MyJsonObject deserializedJson = JsonUtility.FromJson <MyJsonObject>(json);
    }
Beispiel #5
0
    public void DoJsonExampleHashed()
    {
        MyJsonObject jsonObject = new MyJsonObject()
        {
            MyInteger = 24,
            MyString  = "Hello World!",
            MyBoolean = false
        };

        // The object now references itself!
        jsonObject.MyNestedReference = jsonObject;

        // Set the enableHashing parameter to true,
        // so the object can reference itself.
        string json = JsonUtility.ToJson(jsonObject, true);

        Console.WriteLine(json);

        // And with the same simple line it is converted back!
        MyJsonObject deserializedJson = JsonUtility.FromJson <MyJsonObject>(json);
    }