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"); }
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"); }
public void JsonPathSetTopLevelValue() { string modifiedJson = JsonPath.SetValueForJsonPath(this.GetJson(), "$.id", "5678"); dynamic result = JsonConvert.DeserializeObject(modifiedJson); Assert.AreEqual(JsonPath.ConvertValueForOutput(result.id), "5678"); }
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"); }
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"); }