diff --git a/lib_json/src/main/x/json.x b/lib_json/src/main/x/json.x index fd0dcbae2b..dae3947728 100644 --- a/lib_json/src/main/x/json.x +++ b/lib_json/src/main/x/json.x @@ -24,27 +24,22 @@ module json.xtclang.org /** * JSON types include primitive types, array types, and map types. */ - typedef (Primitive | Map | Array) as Doc; - - /** - * A type representing a JSON Object. - */ - typedef Map as JsonObject; + typedef (Primitive | Map | Doc[]) as Doc; /** * A type representing a JSON Array. */ - typedef Array as JsonArray; + typedef Doc[] as JsonArray; /** * A type representing a non-primitive JSON structure. */ - typedef JsonObject | JsonArray as JsonStruct; + typedef Map | JsonArray as JsonStruct; /** - * @return a new instance of a mutable `JsonObject` + * @return a new instance of a mutable [JsonObject]. */ - JsonObject newObject() = new ListMap(); + JsonObject newObject(Map map = []) = new JsonObject(map); /** * @return a builder that can produce immutable JSON object instances @@ -54,7 +49,7 @@ module json.xtclang.org /** * @return a new instance of a mutable `JsonArray` */ - JsonArray newArray() = new Array(); + JsonArray newArray() = new Doc[]; /** * @return a builder that can produce immutable JSON array instances diff --git a/lib_json/src/main/x/json/JsonArrayBuilder.x b/lib_json/src/main/x/json/JsonArrayBuilder.x index d5b530c286..32e1550ce9 100644 --- a/lib_json/src/main/x/json/JsonArrayBuilder.x +++ b/lib_json/src/main/x/json/JsonArrayBuilder.x @@ -7,7 +7,7 @@ class JsonArrayBuilder /** * A type that is a function that can create a new instance of a mutable `JsonArray`. */ - typedef function JsonArray () as Factory; + typedef function JsonArray() as Factory; /** * Create a JSON array builder. @@ -18,7 +18,7 @@ class JsonArrayBuilder */ construct(JsonArray? template = Null, Factory factory = () -> json.newArray()) { this.factory = factory; - values = new Array(); + values = new Doc[]; if (template.is(JsonArray)) { values.addAll(template); } @@ -32,7 +32,7 @@ class JsonArrayBuilder /** * The array of values to be used to create a JSON array. */ - private Array values; + private Doc[] values; /** * @return the number of values that have been added to the builder. diff --git a/lib_json/src/main/x/json/JsonObject.x b/lib_json/src/main/x/json/JsonObject.x new file mode 100644 index 0000000000..78d122cdb9 --- /dev/null +++ b/lib_json/src/main/x/json/JsonObject.x @@ -0,0 +1,35 @@ +/** + * JSON Object. + */ +@AutoFreezable +class JsonObject + implements Freezable + delegates Map(jsonObject) { + + construct(Map map = []) { + jsonObject = new ListMap(); + if (!map.empty) { + jsonObject.putAll(map); + } + } + + private Map jsonObject; + + @Override + immutable Freezable freeze(Boolean inPlace = False) = makeImmutable(); + + @Override + @Op("[]") Value? getOrNull(Key key) = super(key); + + @Override + @Op("[]=") void putInPlace(Key key, Value value) = super(key, value); + + // this doesn't work atm, but it should; will make put ops more usable +// @Op("[]=") void putInPlace(Key key, Int value) = putInPlace(key, value.toIntLiteral()); +// +// @Op("[]=") void putInPlace(Key key, FPNumber value) = putInPlace(key, value.toIntLiteral()); + + @Auto + Doc toDoc() = jsonObject; +} + diff --git a/manualTests/src/main/x/TestSimple.x b/manualTests/src/main/x/TestSimple.x index 15795f01df..1459304f54 100644 --- a/manualTests/src/main/x/TestSimple.x +++ b/manualTests/src/main/x/TestSimple.x @@ -1,63 +1,31 @@ module TestSimple { - import ecstasy.collections.NaturalHasher; + package json import json.xtclang.org; @Inject Console console; + import json.*; + void run() { - Char a = 'a'; - Char b = 'b'; - console.print(a.hashCode()); - console.print(new NaturalHasher().hashOf(a)); - - console.print(a==b); - console.print(new NaturalHasher().areEqual(a, b)); - - console.print(a<=>b); - - try { - Hashable h = obfuscate(a); - console.print(h.hashCode()); - } - catch (Exception e) { - console.print(e); - } - try { - Const c = obfuscate(a); - console.print(c.hashCode()); - } - catch (Exception e) { - console.print(e); - } + Test t = new Test(); + console.print(t.getObject()); + console.print(t.getDoc()); - try { - Orderable c1 = obfuscate(a); - Orderable c2 = obfuscate(b); - console.print(c1 <=> c2); - } - catch (Exception e) { - console.print(e); - } + } + + service Test { - try { - Const c1 = obfuscate(a); - Const c2 = obfuscate(b); - console.print(c1 == c2); - } - catch (Exception e) { - console.print(e); + JsonObject getObject(Int i = 1) { + JsonObject o = json.newObject(); + o["a"] = i /*this will not be needed*/.toIntLiteral(); + return o; // no need to freeze } - try { - Const c1 = obfuscate(a); - Const c2 = obfuscate(b); - console.print(c1 <=> c2); - } - catch (Exception e) { - console.print(e); + Doc getDoc(Dec d = 1) { + JsonObject o = json.newObject(); + o["a"] = d/*this will not be needed*/.toFPLiteral(); + return o; } } - - T obfuscate(Object o) = o.as(T); } \ No newline at end of file diff --git a/manualTests/src/main/x/json/json_test/JsonArrayTest.x b/manualTests/src/main/x/json/json_test/JsonArrayTest.x index 0bdb8506e8..0bc5a3c9d6 100644 --- a/manualTests/src/main/x/json/json_test/JsonArrayTest.x +++ b/manualTests/src/main/x/json/json_test/JsonArrayTest.x @@ -41,9 +41,9 @@ class JsonArrayTest { .add(json.objectBuilder().add("one", 1).add("two", 2).add("three", 3).add("four", 4)) .add(json.objectBuilder().add("five", 5).add("six", 6)) .build(); - assert array == Array:[ - Map:["one"=1, "two"=2, "three"=3, "four"=4], - Map:["five"=5, "six"=6] + assert array == Doc[]:[ + ["one"=1, "two"=2, "three"=3, "four"=4], + ["five"=5, "six"=6] ]; } diff --git a/manualTests/src/main/x/json/json_test/JsonBuilderTest.x b/manualTests/src/main/x/json/json_test/JsonBuilderTest.x index 120ca7239c..a26b88fd42 100644 --- a/manualTests/src/main/x/json/json_test/JsonBuilderTest.x +++ b/manualTests/src/main/x/json/json_test/JsonBuilderTest.x @@ -23,32 +23,32 @@ class JsonBuilderTest { @Test void shouldCopySimpleObject() { - JsonObject object = hideCompileType(Map:["one"=11, "two"=22, "three"=33]); + JsonObject object = json.newObject(["one"=11, "two"=22, "three"=33]); JsonObject result = JsonBuilder.deepCopy(object); assertDeepCopy(object, result); } @Test void shouldCopySimpleArray() { - JsonArray array = hideCompileType(Array:[1, 2, 3]); + JsonArray array = hideCompileType([1, 2, 3]); JsonArray result = JsonBuilder.deepCopy(array); assertDeepCopy(array, result); } @Test void shouldCopyComplexObject() { - JsonObject child = Map:["one"=11, "two"=22, "three"=33]; - JsonArray array = Array:[1, 2, 3]; - JsonObject object = Map:["one"=child, "two"=array, "three"=33]; + JsonObject child = json.newObject(["one"=11, "two"=22, "three"=33]); + JsonArray array = [1, 2, 3]; + JsonObject object = json.newObject(["one"=child, "two"=array, "three"=33]); JsonObject result = JsonBuilder.deepCopy(object); assertDeepCopy(object, result); } @Test void shouldCopyComplexArray() { - JsonArray child = Array:[1, 2, 3]; - JsonObject object = Map:["one"=11, "two"=22, "three"=33]; - JsonArray array = Array:[child, object]; + JsonArray child = [1, 2, 3]; + JsonObject object = json.newObject(["one"=11, "two"=22, "three"=33]); + JsonArray array = [child, object]; JsonArray result = JsonBuilder.deepCopy(array); assertDeepCopy(array, result); } @@ -94,64 +94,64 @@ class JsonBuilderTest { @Test void shouldMergeSimpleObjectIntoObject() { - JsonObject target = Map:["a"="b"]; - JsonObject source = Map:["c"="d"]; + JsonObject target = json.newObject(["a"="b"]); + JsonObject source = json.newObject(["c"="d"]); JsonObject result = new JsonObjectBuilder(target).deepMerge(source).build(); - assert result == Map:["a"="b", "c"="d"]; + assert result == json.newObject(["a"="b", "c"="d"]); } @Test void shouldMergeComplexObjectIntoObject() { - JsonObject target = Map:["a"="b"]; - JsonObject source = Map:["c"=Map:["one"="two"]]; + JsonObject target = json.newObject(["a"="b"]); + JsonObject source = json.newObject(["c"=["one"="two"]]); JsonObject result = new JsonObjectBuilder(target).deepMerge(source).build(); - assert result == Map:["a"="b", "c"=Map:["one"="two"]]; + assert result == json.newObject(["a"="b", "c"=["one"="two"]]); } @Test void shouldMergeArrayIntoObject() { - JsonObject target = Map:["a"="b"]; + JsonObject target = json.newObject(["a"="b"]); JsonArray source = [1, 2, 3]; JsonObject result = new JsonObjectBuilder(target).deepMerge(source).build(); - assert result == Map:["a"="b", "0"=1, "1"=2, "2"=3]; + assert result == json.newObject(["a"="b", "0"=1, "1"=2, "2"=3]); } @Test void shouldMergeObjectWithObjectIntoObjectWithExistingObject() { - JsonObject target = Map:["a"="b", "c"=Map:["one"=1, "two"=2]]; - JsonObject source = Map:["c"=Map:["two"=22, "three"=3]]; + JsonObject target = json.newObject(["a"="b", "c"=["one"=1, "two"=2]]); + JsonObject source = json.newObject(["c"=["two"=22, "three"=3]]); JsonObject result = new JsonObjectBuilder(target).deepMerge(source).build(); - assert result == Map:["a"="b", "c"=Map:["one"=1, "two"=22, "three"=3]]; + assert result == json.newObject(["a"="b", "c"=["one"=1, "two"=22, "three"=3]]); } @Test void shouldMergeObjectWithObjectIntoObjectWithExistingArray() { - JsonObject target = Map:["a"="b", "c"=Array:["one", "two", "three"]]; - JsonObject source = Map:["c"=Map:["0"="one-updated", "2"="three-updated"]]; + JsonObject target = json.newObject(["a"="b", "c"=["one", "two", "three"]]); + JsonObject source = json.newObject(["c"=["0"="one-updated", "2"="three-updated"]]); JsonObject result = new JsonObjectBuilder(target).deepMerge(source).build(); - assert result == Map:["a"="b", "c"=Array:["one-updated", "two", "three-updated"]]; + assert result == json.newObject(["a"="b", "c"=["one-updated", "two", "three-updated"]]); } @Test void shouldMergeObjectWithObjectIntoObjectWithExistingComplexArray() { - JsonObject objOrig0 = Map:["one"=1, "two"=2]; - JsonObject objOrig1 = Map:["three"=3, "four"=4, "five"=5]; - JsonObject objOrig2 = Map:["six"=6, "seven"=7]; - JsonObject target = Map:["a"="b", "c"=Array:[objOrig0, objOrig1, objOrig2]]; - JsonObject objUpdate1 = Map:["four"=44]; - JsonObject objExpected1 = Map:["three"=3, "four"=44, "five"=5]; - JsonObject source = Map:["c"=Map:["1"=objUpdate1]]; + JsonObject objOrig0 = json.newObject(["one"=1, "two"=2]); + JsonObject objOrig1 = json.newObject(["three"=3, "four"=4, "five"=5]); + JsonObject objOrig2 = json.newObject(["six"=6, "seven"=7]); + JsonObject target = json.newObject(["a"="b", "c"=[objOrig0, objOrig1, objOrig2]]); + JsonObject objUpdate1 = json.newObject(["four"=44]); + JsonObject objExpected1 = json.newObject(["three"=3, "four"=44, "five"=5]); + JsonObject source = json.newObject(["c"=["1"=objUpdate1]]); JsonObject result = new JsonObjectBuilder(target).deepMerge(source).build(); Doc c = result["c"]; - assert c.is(Array); - assert c == Array:[objOrig0, objExpected1, objOrig2]; - //assert result == Map:["a"="b", "c"=Array:[objOrig0, objExpected1, objOrig2]]; + assert c.is(Doc[]); + assert c == Doc[]:[objOrig0, objExpected1, objOrig2]; + //assert result == json.newObject(["a"="b", "c"=Doc[]:[objOrig0, objExpected1, objOrig2]]); } @Test void shouldNotMergeObjectWithObjectWithNonIntKeysIntoObjectWithExistingArray() { - JsonObject target = Map:["a"="b", "c"=Array:["one", "two", "three"]]; - JsonObject source = Map:["c"=Map:["0"="one-updated", "three"="three-updated"]]; + JsonObject target = json.newObject(["a"="b", "c"=["one", "two", "three"]]); + JsonObject source = json.newObject(["c"=["0"="one-updated", "three"="three-updated"]]); JsonObjectBuilder builder = new JsonObjectBuilder(target); try { builder.deepMerge(source); @@ -160,13 +160,13 @@ class JsonBuilderTest { // expected } // target should be unchanged - assert target == Map:["a"="b", "c"=Array:["one", "two", "three"]]; + assert target == json.newObject(["a"="b", "c"=["one", "two", "three"]]); } @Test void shouldNotMergeObjectWithObjectWithOutOfRangeKeysIntoObjectWithExistingArray() { - JsonObject target = Map:["a"="b", "c"=Array:["one", "two", "three"]]; - JsonObject source = Map:["c"=Map:["0"="one-updated", "3"="four"]]; + JsonObject target = json.newObject(["a"="b", "c"=["one", "two", "three"]]); + JsonObject source = json.newObject(["c"=["0"="one-updated", "3"="four"]]); JsonObjectBuilder builder = new JsonObjectBuilder(target); try { builder.deepMerge(source); @@ -175,14 +175,14 @@ class JsonBuilderTest { // expected } // target should be unchanged - assert target == Map:["a"="b", "c"=Array:["one", "two", "three"]]; + assert target == json.newObject(["a"="b", "c"=["one", "two", "three"]]); } @Test void shouldMergeObjectWithPrimitiveIntoObjectWithExistingPrimitive() { - JsonObject target = Map:["a"="b", "c"="d"]; - JsonObject source = Map:["c"="updated"]; + JsonObject target = json.newObject(["a"="b", "c"="d"]); + JsonObject source = json.newObject(["c"="updated"]); JsonObject result = new JsonObjectBuilder(target).deepMerge(source).build(); - assert result == Map:["a"="b", "c"="updated"]; + assert result == json.newObject(["a"="b", "c"="updated"]); } } \ No newline at end of file diff --git a/manualTests/src/main/x/json/json_test/patch/JsonPatchAddTest.x b/manualTests/src/main/x/json/json_test/patch/JsonPatchAddTest.x index f75a4a1f10..6de68c2960 100644 --- a/manualTests/src/main/x/json/json_test/patch/JsonPatchAddTest.x +++ b/manualTests/src/main/x/json/json_test/patch/JsonPatchAddTest.x @@ -119,7 +119,7 @@ class JsonPatchAddTest { JsonPatch patch = JsonPatch.builder().add("/-2", "new").build(); Doc result = patch.apply(array, new JsonPatch.Options(supportNegativeIndices = True)); assert result.is(JsonArray); - assert result == Array:["one", "new", "two", "three"]; + assert result == ["one", "new", "two", "three"]; } @Test @@ -161,7 +161,7 @@ class JsonPatchAddTest { assert result.is(JsonObject); assert result.size == 1; assert result["one"].is(JsonArray); - assert result["one"].as(JsonArray) == Array:["one", "added", "two", "three"]; + assert result["one"].as(JsonArray) == ["one", "added", "two", "three"]; } @Test @@ -173,7 +173,7 @@ class JsonPatchAddTest { assert result.is(JsonObject); assert result.size == 1; assert result["one"].is(JsonArray); - assert result["one"].as(JsonArray) == Array:["one", "two", "added", "three"]; + assert result["one"].as(JsonArray) == ["one", "two", "added", "three"]; } @Test @@ -187,7 +187,7 @@ class JsonPatchAddTest { |} ; - JsonObject value = Map:["a"="b"]; + JsonObject value = json.newObject(["a"="b"]); JsonPatch.Operation expected = new JsonPatch.Operation(Add, JsonPointer.from("/one/two"), value); assertOperation(jsonOp, expected); } diff --git a/manualTests/src/main/x/json/json_test/patch/JsonPatchMoveTest.x b/manualTests/src/main/x/json/json_test/patch/JsonPatchMoveTest.x index 1f59396fd0..d07963f1b4 100644 --- a/manualTests/src/main/x/json/json_test/patch/JsonPatchMoveTest.x +++ b/manualTests/src/main/x/json/json_test/patch/JsonPatchMoveTest.x @@ -45,7 +45,7 @@ class JsonPatchMoveTest { JsonPatch patch = JsonPatch.builder().move("/one", "/two").build(); Doc result = patch.apply(target); assert result.is(JsonObject); - assert result == Map:["two"=child, "three"=33]; + assert result == json.newObject(["two"=child, "three"=33]); } @Test @@ -133,7 +133,7 @@ class JsonPatchMoveTest { JsonPatch patch = JsonPatch.builder().move("/1", "/-").build(); Doc result = patch.apply(target); assert result.is(JsonArray); - assert result == Array:[1, 2, 3, child]; + assert result == Doc[]:[1, 2, 3, child]; } @Test @@ -143,7 +143,7 @@ class JsonPatchMoveTest { JsonPatch patch = JsonPatch.builder().move("/1", "/-1").build(); Doc result = patch.apply(target, new JsonPatch.Options(supportNegativeIndices = True)); assert result.is(JsonArray); - assert result == Array:[1, 2, child, 3]; + assert result == Doc[]:[1, 2, child, 3]; } @Test @@ -153,7 +153,7 @@ class JsonPatchMoveTest { JsonPatch patch = JsonPatch.builder().move("/-4", "/-1").build(); Doc result = patch.apply(target, new JsonPatch.Options(supportNegativeIndices = True)); assert result.is(JsonArray); - assert result == Array:[1, 2, child, 3]; + assert result == Doc[]:[1, 2, child, 3]; } @Test @@ -163,7 +163,7 @@ class JsonPatchMoveTest { JsonPatch patch = JsonPatch.builder().move("/1", "/-").build(); Doc result = patch.apply(target); assert result.is(JsonArray); - assert result == Array:[1, 2, 3, child]; + assert result == Doc[]:[1, 2, 3, child]; } @Test @@ -173,7 +173,7 @@ class JsonPatchMoveTest { JsonPatch patch = JsonPatch.builder().move("/1", "/2").build(); Doc result = patch.apply(target); assert result.is(JsonArray); - assert result == Array:["one", "two", child, "three"]; + assert result == Doc[]:["one", "two", child, "three"]; } @Test @@ -183,7 +183,7 @@ class JsonPatchMoveTest { JsonPatch patch = JsonPatch.builder().move("/1", "/2").build(); Doc result = patch.apply(target); assert result.is(JsonArray); - assert result == Array:[1, 2, child, 3]; + assert result == Doc[]:[1, 2, child, 3]; } @Test @@ -192,7 +192,7 @@ class JsonPatchMoveTest { JsonPatch patch = JsonPatch.builder().move("/1", "/-").build(); Doc result = patch.apply(target); assert result.is(JsonArray); - assert result == Array:[1, 3, 4, 2]; + assert result == Doc[]:[1, 3, 4, 2]; } @Test @@ -201,7 +201,7 @@ class JsonPatchMoveTest { JsonPatch patch = JsonPatch.builder().move("/1", "/3").build(); Doc result = patch.apply(target); assert result.is(JsonArray); - assert result == Array:[1, 3, 4, 2, 5]; + assert result == Doc[]:[1, 3, 4, 2, 5]; } @Test diff --git a/manualTests/src/main/x/json/json_test/patch/JsonPatchRemoveTest.x b/manualTests/src/main/x/json/json_test/patch/JsonPatchRemoveTest.x index db5f1bec6d..e680e97199 100644 --- a/manualTests/src/main/x/json/json_test/patch/JsonPatchRemoveTest.x +++ b/manualTests/src/main/x/json/json_test/patch/JsonPatchRemoveTest.x @@ -108,7 +108,7 @@ class JsonPatchRemoveTest { |} ; - JsonObject value = Map:["a"="b"]; + JsonObject value = json.newObject(["a"="b"]); JsonPatch.Operation expected = new JsonPatch.Operation(Remove, JsonPointer.from("/one/two")); assertOperation(jsonOp, expected); } diff --git a/manualTests/src/main/x/json/json_test/patch/JsonPatchReplaceTest.x b/manualTests/src/main/x/json/json_test/patch/JsonPatchReplaceTest.x index c0e0175f2a..ef023f3da6 100644 --- a/manualTests/src/main/x/json/json_test/patch/JsonPatchReplaceTest.x +++ b/manualTests/src/main/x/json/json_test/patch/JsonPatchReplaceTest.x @@ -151,7 +151,7 @@ class JsonPatchReplaceTest { |} ; - JsonObject value = Map:["a"="b"]; + JsonObject value = json.newObject(["a"="b"]); JsonPatch.Operation expected = new JsonPatch.Operation(Replace, JsonPointer.from("/one/two"), value); assertOperation(jsonOp, expected); } diff --git a/manualTests/src/main/x/json/json_test/patch/JsonPatchTestTest.x b/manualTests/src/main/x/json/json_test/patch/JsonPatchTestTest.x index 511c30c74e..e3c73ef6ad 100644 --- a/manualTests/src/main/x/json/json_test/patch/JsonPatchTestTest.x +++ b/manualTests/src/main/x/json/json_test/patch/JsonPatchTestTest.x @@ -49,7 +49,7 @@ class JsonPatchTestTest { @Test void shouldSucceedTestingObject() { - Doc target = Map:["one"=1, "two"=2, "three"=3]; + Doc target = ["one"=1, "two"=2, "three"=3]; JsonPatch patch = JsonPatch.builder().test("/two", 2).build(); Doc result = patch.apply(target); assert result == target; @@ -57,15 +57,15 @@ class JsonPatchTestTest { @Test void shouldFailTestingObject() { - Doc target = Map:["one"=1, "two"=2, "three"=3]; + Doc target = ["one"=1, "two"=2, "three"=3]; JsonPatch patch = JsonPatch.builder().test("/two", 200).build(); IllegalState error = assertThrows(() -> patch.apply(target)); } @Test void shouldSucceedTestingChildObject() { - Doc child = Map:["one"=1, "two"=2, "three"=3]; - Doc target = Map:["foo"=child]; + Doc child = ["one"=1, "two"=2, "three"=3]; + Doc target = ["foo"=child]; JsonPatch patch = JsonPatch.builder().test("/foo/two", 2).build(); Doc result = patch.apply(target); assert result == target; @@ -73,16 +73,16 @@ class JsonPatchTestTest { @Test void shouldFailTestingChildObject() { - Doc child = Map:["one"=1, "two"=2, "three"=3]; - Doc target = Map:["foo"=child]; + Doc child = ["one"=1, "two"=2, "three"=3]; + Doc target = ["foo"=child]; JsonPatch patch = JsonPatch.builder().test("/foo/two", 200).build(); IllegalState error = assertThrows(() -> patch.apply(target)); } @Test void shouldFailTestingMissingChildObject() { - Doc child = Map:["one"=1, "two"=2, "three"=3]; - Doc target = Map:["foo"=child]; + Doc child = ["one"=1, "two"=2, "three"=3]; + Doc target = ["foo"=child]; JsonPatch patch = JsonPatch.builder().test("/foo/four", 4).build(); IllegalState error = assertThrows(() -> patch.apply(target)); } @@ -90,7 +90,7 @@ class JsonPatchTestTest { @Test void shouldSucceedTestingNullChildObject() { Doc child = Map:["one"=1, "two"=Null, "three"=3]; - Doc target = Map:["foo"=child]; + Doc target = ["foo"=child]; JsonPatch patch = JsonPatch.builder().test("/foo/two", Null).build(); Doc result = patch.apply(target); assert result == target; @@ -98,8 +98,8 @@ class JsonPatchTestTest { @Test void shouldSucceedTestingNullMissingChildObject() { - Doc child = Map:["one"=1, "two"=2, "three"=3]; - Doc target = Map:["foo"=child]; + Doc child = ["one"=1, "two"=2, "three"=3]; + Doc target = ["foo"=child]; JsonPatch patch = JsonPatch.builder().test("/foo/four", Null).build(); Doc result = patch.apply(target); assert result == target; @@ -116,7 +116,7 @@ class JsonPatchTestTest { |} ; - JsonObject value = Map:["a"="b"]; + JsonObject value = json.newObject(["a"="b"]); JsonPatch.Operation expected = new JsonPatch.Operation(Test, JsonPointer.from("/one/two"), value); assertOperation(jsonOp, expected); }