Ejemplo n.º 1
0
        public void JsonPathSetNewSecondLevelValue()
        {
            string modifiedJson = JsonPath.SetValueForJsonPath(this.GetJson(), "$.zippy.foo", "do-dah");

            dynamic result = JsonConvert.DeserializeObject(modifiedJson);

            Assert.AreEqual(JsonPath.ConvertValueForOutput(result.zippy.foo), "do-dah");
        }
Ejemplo n.º 2
0
        public void JsonPathSetArrayValue()
        {
            string modifiedJson = JsonPath.SetValueForJsonPath(this.GetJson(), "$.children[0].name", "something-else-completely");

            dynamic result = JsonConvert.DeserializeObject(modifiedJson);

            Assert.AreEqual(JsonPath.ConvertValueForOutput(result.children[0].name), "something-else-completely");
        }
Ejemplo n.º 3
0
        public void JsonPathSetTopLevelValue()
        {
            string modifiedJson = JsonPath.SetValueForJsonPath(this.GetJson(), "$.id", "5678");

            dynamic result = JsonConvert.DeserializeObject(modifiedJson);

            Assert.AreEqual(JsonPath.ConvertValueForOutput(result.id), "5678");
        }
Ejemplo n.º 4
0
        public void JsonPathSetSecondLevelValue()
        {
            string modifiedJson = JsonPath.SetValueForJsonPath(this.GetJson(), "$.another.value", "something-else-completely");

            dynamic result = JsonConvert.DeserializeObject(modifiedJson);

            Assert.AreEqual(JsonPath.ConvertValueForOutput(result.another.value), "something-else-completely");
        }
Ejemplo n.º 5
0
        public void JsonPathComplexTypeName()
        {
            string json = "{ \"name\": \"foobar\" }";

            string  modifiedJson = JsonPath.SetValueForJsonPath(json, "$.['@name.conflictBehavior']", "replace");
            dynamic result       = JsonConvert.DeserializeObject(modifiedJson);

            Assert.AreEqual(JsonPath.ConvertValueForOutput(result["@name.conflictBehavior"]), "replace");
        }