public void ShouldMoveObjectBetweenTwoArray() { dynamic _Object = JObject.Parse(@" {'baz': [{'name': 'foo'},{'name': 'bar'}], 'boo': [{'name': 'zoo'},{'name': 'ear'}]}" ); Operation operation = new MoveOperation() { Target = _Object, From = "$.baz[0]", Path = "$.boo[1]" }; operation.Execute(); string result = SerializeObject(_Object); result.ShouldBe(@"{'baz':[{'name':'bar'}],'boo':[{'name':'zoo'},{'name':'foo'},{'name':'ear'}]}"); }
public void ShouldMoveValueForSimpleProperty() { dynamic _Object = JObject.Parse(@" { 'baz': 'qux', 'foo': 'bar' }" ); Operation operation = new MoveOperation() { Target = _Object, From= "$.baz", Path = "$.boo"}; operation.Execute(); string result = SerializeObject(_Object); result.ShouldBe(@"{'foo':'bar','boo':'qux'}"); }
public void ShouldMoveValueForComplexProperty() { dynamic _Object = JObject.Parse(@" { 'foo': { 'bar': 'baz', 'waldo': 'fred' }, 'qux': { 'corge': 'grault' } }" ); Operation operation = new MoveOperation() { Target = _Object, From="$.foo.waldo", Path="$.qux.thud"}; operation.Execute(); string result = SerializeObject(_Object); result.ShouldBe(@"{'foo':{'bar':'baz'},'qux':{'corge':'grault','thud':'fred'}}"); }