Exemplo n.º 1
0
        public void JN15()
        {
            Dictionary <String, Object> json = new Dictionary <String, Object>();

            Backendless.UserService.Login("*****@*****.**", "123234");
            Dictionary <String, Object> serializeMap = new Dictionary <String, Object>
            {
                { "decimals", new Double[] { 12.5, 14 } },
                { "colours", new String[] { "green", "blue" } }
            };

            json["jsonValue"] = JsonConvert.SerializeObject(serializeMap);

            serializeMap["objectId"] = Backendless.Data.Of("Table1").Save(json)["objectId"];
            json.Clear();
            json["objectId"]  = serializeMap["objectId"];
            json["jsonValue"] = JSONUpdateBuilder.ARRAY_INSERT()
                                .AddArgument("$.decimals[0]", 432)
                                .AddArgument("$.colours[1]", "Yellow")
                                .Create();

            var newMap = Backendless.Data.Of("Table1").Save(json);

            Assert.IsTrue(newMap["objectId"].ToString() == json["objectId"].ToString());
            Assert.IsTrue(newMap["objectId"].ToString() == json["objectId"].ToString());
            Assert.IsTrue(((Dictionary <Object, Object>)newMap["jsonValue"])["rawJsonString"] != null);

            Object expectedJson = "{\"colours\": [\"green\", \"Yellow\", \"blue\"], \"decimals\": [432, 12.5, 14]}";

            Assert.IsTrue(expectedJson.ToString() == ((Dictionary <Object, Object>)newMap["jsonValue"])["rawJsonString"].ToString());

            Backendless.Data.Of("Table1").Remove("'json' != null");
        }
Exemplo n.º 2
0
        public void JN11()
        {
            Dictionary <String, Object> json = new Dictionary <String, Object>();

            Backendless.UserService.Login("*****@*****.**", "123234");
            json["jsonValue"] = "{}";
            json["objectId"]  = Backendless.Data.Of("Table1").Save(json)["objectId"];

            json["jsonValue"] = JSONUpdateBuilder.INSERT()
                                .AddArgument("$.state", "on")
                                .AddArgument("$.number", 11)
                                .Create();

            var newMap = Backendless.Data.Of("Table1").Save(json);

            Assert.IsTrue(newMap["objectId"].ToString() == json["objectId"].ToString());
            Assert.IsTrue(newMap.Keys.Count == 7);
            Assert.IsTrue(((Dictionary <Object, Object>)newMap["jsonValue"])["rawJsonString"] != null);

            Object expectedJson = "{\"state\": \"on\", \"number\": 11}";

            Assert.IsTrue(expectedJson.ToString() == ((Dictionary <Object, Object>)newMap["jsonValue"])["rawJsonString"].ToString());

            Backendless.Data.Of("Table1").Remove("'json' != null");
        }
Exemplo n.º 3
0
        public void JN12()
        {
            Dictionary <String, Object> json = new Dictionary <String, Object>();

            Backendless.UserService.Login("*****@*****.**", "123234");
            Dictionary <String, Object> serializeMap = new Dictionary <String, Object>
            {
                { "letter", "a" },
                { "number", 10 }
            };

            json["jsonValue"] = JsonConvert.SerializeObject(serializeMap);


            serializeMap["objectId"] = Backendless.Data.Of("Table1").Save(json)["objectId"];
            json.Clear();
            json["objectId"]  = serializeMap["objectId"];
            json["jsonValue"] = JSONUpdateBuilder.REPLACE()
                                .AddArgument("$.number", 11)
                                .AddArgument("$.colours", "red")
                                .Create();

            var newMap = Backendless.Data.Of("Table1").Save(json);

            Assert.IsTrue(newMap["objectId"].ToString() == json["objectId"].ToString());
            Assert.IsTrue(newMap["objectId"].ToString() == json["objectId"].ToString());
            Assert.IsTrue(((Dictionary <Object, Object>)newMap["jsonValue"])["rawJsonString"] != null);

            Object expectedJson = "{\"letter\": \"a\", \"number\": 11}";

            Assert.IsTrue(expectedJson.ToString() == ((Dictionary <Object, Object>)newMap["jsonValue"])["rawJsonString"].ToString());

            Backendless.Data.Of("Table1").Remove("'json' != null");
        }
Exemplo n.º 4
0
        public void JN10()
        {
            Dictionary <String, Object> json = new Dictionary <String, Object>();

            Backendless.UserService.Login("*****@*****.**", "123234");
            json["jsonValue"] = "{}";
            json["objectId"]  = Backendless.Data.Of("Table1").Save(json)["objectId"];

            json["jsonValue"] = JSONUpdateBuilder.SET()
                                .AddArgument("$.letter", "b")
                                .AddArgument("$.number", 36)
                                .AddArgument("$.state", true)
                                .AddArgument("$.colours[0]", null)
                                .AddArgument("$.innerValue", new Dictionary <String, Object> {
                { "value", "value" }
            })
                                .Create();

            var newMap = Backendless.Data.Of("Table1").Save(json);

            Assert.IsTrue(newMap["objectId"].ToString() == json["objectId"].ToString());
            Assert.IsTrue(newMap.Keys.Count == 7);
            Assert.IsTrue(((Dictionary <Object, Object>)newMap["jsonValue"])["rawJsonString"] != null);

            Backendless.Data.Of("Table1").Remove("'json' != null");
        }