public void ShouldReplaceValueForArray() { dynamic _Object = JObject.Parse(@" {'baz': [{'name': 'foo'},{'name': 'bar'}]}" ); Operation operation = new ReplaceOperation() { Target = _Object, Path = "$.baz[0].name", Value="boo" }; operation.Execute(); string result = SerializeObject(_Object); result.ShouldBe(@"{'baz':[{'name':'boo'},{'name':'bar'}]}"); }
public void ShouldReplaceValueForComplexProperty() { dynamic _Object = JObject.Parse(@" { 'baz': {'age': 1}, 'foo': 'bar' }" ); Operation operation = new ReplaceOperation() { Target = _Object, Path = "$.baz.age", Value=2}; operation.Execute(); string result = SerializeObject(_Object); result.ShouldBe(@"{'baz':{'age':2},'foo':'bar'}"); }
public void ShouldReplaceValueForSimpleProperty() { dynamic _Object = JObject.Parse(@" { 'baz': 'qux', 'foo': 'bar' }" ); Operation operation = new ReplaceOperation() { Target = _Object, Path = "$.baz", Value="boo"}; operation.Execute(); string result = SerializeObject(_Object); result.ShouldBe(@"{'baz':'boo','foo':'bar'}"); }