diff --git a/.gitignore b/.gitignore index 138bb77159..8a0bc11e97 100644 --- a/.gitignore +++ b/.gitignore @@ -124,3 +124,6 @@ nb-configuration.xml # MacOS jenv .java-version + +# VS Code +.vscode/ diff --git a/CHANGES.md b/CHANGES.md index 70dced76f7..2b60913d67 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,8 @@ This document is intended for Spotless developers. We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`). ## [Unreleased] +### Added +* Add a `jsonPatch` step to `json` formatter configurations. This allows patching of JSON documents using [JSON Patches](https://jsonpatch.com). ([#1753](https://github.com/diffplug/spotless/pull/1753)) ### Fixed * Use latest versions of popular style guides for `eslint` tests to fix failing `useEslintXoStandardRules` test. ([#1761](https://github.com/diffplug/spotless/pull/1761), [#1756](https://github.com/diffplug/spotless/issues/1756)) * Add support for `prettier` version `3.0.0` and newer. ([#1760]https://github.com/diffplug/spotless/pull/1760), [#1751](https://github.com/diffplug/spotless/issues/1751)) diff --git a/README.md b/README.md index 3e0c4e17e1..cd1e736014 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ lib('java.CleanthatJavaStep') +'{{yes}} | {{yes}} lib('json.gson.GsonStep') +'{{yes}} | {{yes}} | {{no}} | {{no}} |', lib('json.JacksonJsonStep') +'{{yes}} | {{yes}} | {{no}} | {{no}} |', lib('json.JsonSimpleStep') +'{{yes}} | {{yes}} | {{no}} | {{no}} |', +lib('json.JsonPatchStep') +'{{yes}} | {{yes}} | {{no}} | {{no}} |', lib('kotlin.KtLintStep') +'{{yes}} | {{yes}} | {{yes}} | {{no}} |', lib('kotlin.KtfmtStep') +'{{yes}} | {{yes}} | {{no}} | {{no}} |', lib('kotlin.DiktatStep') +'{{yes}} | {{yes}} | {{no}} | {{no}} |', @@ -140,6 +141,7 @@ lib('yaml.JacksonYamlStep') +'{{yes}} | {{yes}} | [`json.gson.GsonStep`](lib/src/main/java/com/diffplug/spotless/json/gson/GsonStep.java) | :+1: | :+1: | :white_large_square: | :white_large_square: | | [`json.JacksonJsonStep`](lib/src/main/java/com/diffplug/spotless/json/JacksonJsonStep.java) | :+1: | :+1: | :white_large_square: | :white_large_square: | | [`json.JsonSimpleStep`](lib/src/main/java/com/diffplug/spotless/json/JsonSimpleStep.java) | :+1: | :+1: | :white_large_square: | :white_large_square: | +| [`json.JsonPatchStep`](lib/src/main/java/com/diffplug/spotless/json/JsonPatchStep.java) | :+1: | :+1: | :white_large_square: | :white_large_square: | | [`kotlin.KtLintStep`](lib/src/main/java/com/diffplug/spotless/kotlin/KtLintStep.java) | :+1: | :+1: | :+1: | :white_large_square: | | [`kotlin.KtfmtStep`](lib/src/main/java/com/diffplug/spotless/kotlin/KtfmtStep.java) | :+1: | :+1: | :white_large_square: | :white_large_square: | | [`kotlin.DiktatStep`](lib/src/main/java/com/diffplug/spotless/kotlin/DiktatStep.java) | :+1: | :+1: | :white_large_square: | :white_large_square: | diff --git a/lib/build.gradle b/lib/build.gradle index eeb9d1d1ac..01591e557d 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -20,7 +20,8 @@ def NEEDS_GLUE = [ 'ktlint', 'palantirJavaFormat', 'scalafmt', - 'sortPom' + 'sortPom', + 'zjsonPatch', ] for (glue in NEEDS_GLUE) { sourceSets.register(glue) { @@ -114,6 +115,8 @@ dependencies { // sortPom sortPomCompileOnly 'com.github.ekryd.sortpom:sortpom-sorter:3.2.1' sortPomCompileOnly 'org.slf4j:slf4j-api:2.0.0' + // zjsonPatch + zjsonPatchCompileOnly 'com.flipkart.zjsonpatch:zjsonpatch:0.4.14' } // we'll hold the core lib to a high standard diff --git a/lib/src/main/java/com/diffplug/spotless/json/JsonPatchStep.java b/lib/src/main/java/com/diffplug/spotless/json/JsonPatchStep.java new file mode 100644 index 0000000000..71f4380264 --- /dev/null +++ b/lib/src/main/java/com/diffplug/spotless/json/JsonPatchStep.java @@ -0,0 +1,90 @@ +/* + * Copyright 2023 DiffPlug + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.diffplug.spotless.json; + +import java.io.IOException; +import java.io.Serializable; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import com.diffplug.spotless.FormatterFunc; +import com.diffplug.spotless.FormatterStep; +import com.diffplug.spotless.JarState; +import com.diffplug.spotless.Provisioner; + +public class JsonPatchStep { + // https://mvnrepository.com/artifact/com.flipkart.zjsonpatch/zjsonpatch + static final String MAVEN_COORDINATE = "com.flipkart.zjsonpatch:zjsonpatch"; + static final String DEFAULT_VERSION = "0.4.14"; + + private JsonPatchStep() {} + + public static FormatterStep create(String patchString, Provisioner provisioner) { + return create(DEFAULT_VERSION, patchString, provisioner); + } + + public static FormatterStep create(String zjsonPatchVersion, String patchString, Provisioner provisioner) { + Objects.requireNonNull(zjsonPatchVersion, "zjsonPatchVersion cannot be null"); + Objects.requireNonNull(patchString, "patchString cannot be null"); + Objects.requireNonNull(provisioner, "provisioner cannot be null"); + return FormatterStep.createLazy("apply-json-patch", () -> new State(zjsonPatchVersion, patchString, provisioner), State::toFormatter); + } + + public static FormatterStep create(List> patch, Provisioner provisioner) { + return create(DEFAULT_VERSION, patch, provisioner); + } + + public static FormatterStep create(String zjsonPatchVersion, List> patch, Provisioner provisioner) { + Objects.requireNonNull(zjsonPatchVersion, "zjsonPatchVersion cannot be null"); + Objects.requireNonNull(patch, "patch cannot be null"); + Objects.requireNonNull(provisioner, "provisioner cannot be null"); + return FormatterStep.createLazy("apply-json-patch", () -> new State(zjsonPatchVersion, patch, provisioner), State::toFormatter); + } + + static final class State implements Serializable { + private static final long serialVersionUID = 1L; + + private final JarState jarState; + private final List> patch; + private final String patchString; + + private State(String zjsonPatchVersion, List> patch, Provisioner provisioner) throws IOException { + this.jarState = JarState.from(MAVEN_COORDINATE + ":" + zjsonPatchVersion, provisioner); + this.patch = patch; + this.patchString = null; + } + + private State(String zjsonPatchVersion, String patchString, Provisioner provisioner) throws IOException { + this.jarState = JarState.from(MAVEN_COORDINATE + ":" + zjsonPatchVersion, provisioner); + this.patch = null; + this.patchString = patchString; + } + + FormatterFunc toFormatter() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException { + Class formatterFunc = jarState.getClassLoader().loadClass("com.diffplug.spotless.glue.json.JsonPatchFormatterFunc"); + if (this.patch != null) { + Constructor constructor = formatterFunc.getConstructor(List.class); + return (FormatterFunc) constructor.newInstance(patch); + } else { + Constructor constructor = formatterFunc.getConstructor(String.class); + return (FormatterFunc) constructor.newInstance(patchString); + } + } + } +} diff --git a/lib/src/zjsonPatch/java/com/diffplug/spotless/glue/json/JsonPatchFormatterFunc.java b/lib/src/zjsonPatch/java/com/diffplug/spotless/glue/json/JsonPatchFormatterFunc.java new file mode 100644 index 0000000000..dd2f053791 --- /dev/null +++ b/lib/src/zjsonPatch/java/com/diffplug/spotless/glue/json/JsonPatchFormatterFunc.java @@ -0,0 +1,55 @@ +/* + * Copyright 2023 DiffPlug + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.diffplug.spotless.glue.json; + +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.flipkart.zjsonpatch.JsonPatch; + +import com.diffplug.spotless.FormatterFunc; + +public class JsonPatchFormatterFunc implements FormatterFunc { + private final ObjectMapper objectMapper; + private final List> patch; + private final String patchString; + + public JsonPatchFormatterFunc(String patchString) { + this.objectMapper = new ObjectMapper(); + this.patch = null; + this.patchString = patchString; + } + + public JsonPatchFormatterFunc(List> patch) { + this.objectMapper = new ObjectMapper(); + this.patch = patch; + this.patchString = null; + } + + @Override + public String apply(String input) throws Exception { + var patchNode = this.patch == null + ? objectMapper.readTree(patchString) + : objectMapper.valueToTree(patch); + + var inputNode = objectMapper.readTree(input); + + var patchedNode = JsonPatch.apply(patchNode, inputNode); + + return objectMapper.writeValueAsString(patchedNode); + } +} diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md index 59f98c1127..b21debb36f 100644 --- a/plugin-gradle/CHANGES.md +++ b/plugin-gradle/CHANGES.md @@ -3,6 +3,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`). ## [Unreleased] +### Added +* Add a `jsonPatch` step to `json` formatter configurations. This allows patching of JSON documents using [JSON Patches](https://jsonpatch.com). ([#1753](https://github.com/diffplug/spotless/pull/1753)) ### Fixed * Add support for `prettier` version `3.0.0` and newer. ([#1760]https://github.com/diffplug/spotless/pull/1760), [#1751](https://github.com/diffplug/spotless/issues/1751)) * Fix npm install calls when npm cache is not up-to-date. ([#1760]https://github.com/diffplug/spotless/pull/1760), [#1750](https://github.com/diffplug/spotless/issues/1750)) diff --git a/plugin-gradle/README.md b/plugin-gradle/README.md index 3484e3cd59..b08c8b85bc 100644 --- a/plugin-gradle/README.md +++ b/plugin-gradle/README.md @@ -811,6 +811,7 @@ spotless { gson() // has its own section below jackson() // has its own section below rome() // has its own section below + jsonPatch([]) // has its own section below } } ``` @@ -872,6 +873,49 @@ spotless { } ``` +### jsonPatch + +Uses [zjsonpatch](https://github.com/flipkart-incubator/zjsonpatch) to apply [JSON Patches](https://jsonpatch.com/) as per [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902/) to JSON documents. + +This enables you to add, replace or remove properties at locations in the JSON document that you specify using [JSON Pointers](https://datatracker.ietf.org/doc/html/rfc6901/). + +In Spotless Gradle, these JSON patches are represented as a `List>`, or a list of patch operations. + +Each patch operation must be a map with the following properties: + +* `"op"` - the operation to apply, one of `"replace"`, `"add"` or `"remove"`. +* `"path"` - a JSON Pointer string, for example `"/foo"` +* `"value"` - the value to `"add"` or `"replace"` at the specified path. Not needed for `"remove"` operations. + +For example, to apply the patch from the [JSON Patch homepage](https://jsonpatch.com/#the-patch): + +```gradle +spotless { + json { + target 'src/**/*.json' + jsonPatch([ + [op: 'replace', path: '/baz', value: 'boo'], + [op: 'add', path: '/hello', value: ['world']], + [op: 'remove', path: '/foo'] + ]) + } +} +``` + +Or using the Kotlin DSL: + +```kotlin +spotless { + json { + target("src/**/*.json") + jsonPatch(listOf( + mapOf("op" to "replace", "path" to "/baz", "value" to "boo"), + mapOf("op" to "add", "path" to "/hello", "value" to listOf("world")), + mapOf("op" to "remove", "path" to "/foo") + )) + } +} +``` ## YAML diff --git a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/JsonExtension.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/JsonExtension.java index 2fa567472f..8648cacea9 100644 --- a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/JsonExtension.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/JsonExtension.java @@ -16,18 +16,22 @@ package com.diffplug.gradle.spotless; import java.util.Collections; +import java.util.List; +import java.util.Map; import javax.inject.Inject; import com.diffplug.spotless.FormatterStep; import com.diffplug.spotless.json.JacksonJsonConfig; import com.diffplug.spotless.json.JacksonJsonStep; +import com.diffplug.spotless.json.JsonPatchStep; import com.diffplug.spotless.json.JsonSimpleStep; import com.diffplug.spotless.json.gson.GsonStep; public class JsonExtension extends FormatExtension { private static final int DEFAULT_INDENTATION = 4; private static final String DEFAULT_GSON_VERSION = "2.10.1"; + private static final String DEFAULT_ZJSONPATCH_VERSION = "0.4.14"; static final String NAME = "json"; @Inject @@ -71,6 +75,14 @@ public RomeJson rome(String version) { return romeConfig; } + public JsonPatchConfig jsonPatch(List> patch) { + return new JsonPatchConfig(patch); + } + + public JsonPatchConfig jsonPatch(String zjsonPatchVersion, List> patch) { + return new JsonPatchConfig(zjsonPatchVersion, patch); + } + public class SimpleConfig { private int indent; @@ -191,4 +203,29 @@ protected RomeJson getThis() { return this; } } + + public class JsonPatchConfig { + private String zjsonPatchVersion; + private List> patch; + + public JsonPatchConfig(List> patch) { + this(DEFAULT_ZJSONPATCH_VERSION, patch); + } + + public JsonPatchConfig(String zjsonPatchVersion, List> patch) { + this.zjsonPatchVersion = zjsonPatchVersion; + this.patch = patch; + addStep(createStep()); + } + + public JsonPatchConfig version(String zjsonPatchVersion) { + this.zjsonPatchVersion = zjsonPatchVersion; + replaceStep(createStep()); + return this; + } + + private FormatterStep createStep() { + return JsonPatchStep.create(zjsonPatchVersion, patch, provisioner()); + } + } } diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/JsonExtensionTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/JsonExtensionTest.java index a878615eaa..73e443b915 100644 --- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/JsonExtensionTest.java +++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/JsonExtensionTest.java @@ -156,4 +156,44 @@ void jacksonFormattingWithSortingByKeys() throws IOException { gradleRunner().withArguments("spotlessApply").build(); assertFile("src/main/resources/example.json").sameAsResource("json/sortByKeysAfter_Jackson.json"); } + + @Test + void jsonPatchReplaceString() throws IOException { + setFile("build.gradle").toLines( + "plugins {", + " id 'java'", + " id 'com.diffplug.spotless'", + "}", + "repositories { mavenCentral() }", + "spotless {", + " json {", + " target 'src/**/*.json'", + " jsonPatch([[op: 'replace', path: '/abc', value: 'ghi']])", + " gson()", + " }", + "}"); + setFile("src/main/resources/example.json").toResource("json/patchObjectBefore.json"); + gradleRunner().withArguments("spotlessApply").build(); + assertFile("src/main/resources/example.json").sameAsResource("json/patchObjectAfterReplaceString.json"); + } + + @Test + void jsonPatchReplaceWithObject() throws IOException { + setFile("build.gradle").toLines( + "plugins {", + " id 'java'", + " id 'com.diffplug.spotless'", + "}", + "repositories { mavenCentral() }", + "spotless {", + " json {", + " target 'src/**/*.json'", + " jsonPatch([[op: 'replace', path: '/abc', value: [def: 'ghi']]])", + " gson()", + " }", + "}"); + setFile("src/main/resources/example.json").toResource("json/patchObjectBefore.json"); + gradleRunner().withArguments("spotlessApply").build(); + assertFile("src/main/resources/example.json").sameAsResource("json/patchObjectAfterReplaceWithObject.json"); + } } diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index 9c5396e535..bab8fca7b3 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -3,6 +3,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`). ## [Unreleased] +### Added +* Add a `jsonPatch` step to `json` formatter configurations. This allows patching of JSON documents using [JSON Patches](https://jsonpatch.com). ([#1753](https://github.com/diffplug/spotless/pull/1753)) ### Fixed * Add support for `prettier` version `3.0.0` and newer. ([#1760]https://github.com/diffplug/spotless/pull/1760), [#1751](https://github.com/diffplug/spotless/issues/1751)) * Fix npm install calls when npm cache is not up-to-date. ([#1760]https://github.com/diffplug/spotless/pull/1760), [#1750](https://github.com/diffplug/spotless/issues/1750)) diff --git a/plugin-maven/README.md b/plugin-maven/README.md index 62f2a4ea57..8c56aaefa1 100644 --- a/plugin-maven/README.md +++ b/plugin-maven/README.md @@ -897,10 +897,11 @@ For details, see the [npm detection](#npm-detection), [`.npmrc` detection](#npmr src/**/*.json - - - - + + + + + ``` @@ -957,6 +958,21 @@ Uses Jackson for formatting. +### jsonPatch + +Uses [zjsonpatch](https://github.com/flipkart-incubator/zjsonpatch) to apply [JSON Patches](https://jsonpatch.com/) as per [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902/) to JSON documents. + +This enables you to add, replace or remove properties at locations in the JSON document that you specify using [JSON Pointers](https://datatracker.ietf.org/doc/html/rfc6901/). + +For example, to apply the patch from the [JSON Patch homepage](https://jsonpatch.com/#the-patch): + +```xml +[ + { "op": "replace", "path": "/baz", "value": "boo" }, + { "op": "add", "path": "/hello", "value": ["world"] }, + { "op": "remove", "path": "/foo" } +] +``` ## YAML diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/json/Json.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/json/Json.java index adbb2b7883..be5782b651 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/json/Json.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/json/Json.java @@ -53,4 +53,8 @@ public void addJackson(JacksonJson jackson) { public void addRome(RomeJson rome) { addStepFactory(rome); } + + public void addJsonPatch(JsonPatch jsonPatch) { + addStepFactory(jsonPatch); + } } diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/json/JsonPatch.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/json/JsonPatch.java new file mode 100644 index 0000000000..a822ad09e2 --- /dev/null +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/json/JsonPatch.java @@ -0,0 +1,41 @@ +/* + * Copyright 2023 DiffPlug + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.diffplug.spotless.maven.json; + +import org.apache.maven.plugins.annotations.Parameter; + +import com.diffplug.spotless.FormatterStep; +import com.diffplug.spotless.json.JsonPatchStep; +import com.diffplug.spotless.maven.FormatterStepConfig; +import com.diffplug.spotless.maven.FormatterStepFactory; + +/** + * A {@link FormatterStepFactory} implementation that corresponds to {@code ...} configuration element. + */ +public class JsonPatch implements FormatterStepFactory { + private static final String DEFAULT_ZJSONPATCH_VERSION = "0.4.14"; + + @Parameter + String zjsonPatchVersion = DEFAULT_ZJSONPATCH_VERSION; + + @Parameter + String patch; + + @Override + public FormatterStep newFormatterStep(FormatterStepConfig stepConfig) { + return JsonPatchStep.create(zjsonPatchVersion, patch, stepConfig.getProvisioner()); + } +} diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/json/JsonTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/json/JsonTest.java index 1897cc764a..4c2f05532c 100644 --- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/json/JsonTest.java +++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/json/JsonTest.java @@ -90,4 +90,23 @@ public void testFormatJson_WithJackson_sortByKeys_spaceAfterKeySeparator() throw assertFile("json_test.json").sameAsResource("json/sortByKeysAfter_Jackson_spaceAfterKeySeparator.json"); } + @Test + public void testFormatJson_JsonPatch_replaceString() throws Exception { + writePomWithJsonSteps("[{\"op\":\"replace\",\"path\":\"/abc\",\"value\":\"ghi\"}]"); + + setFile("json_test.json").toResource("json/patchObjectBefore.json"); + + mavenRunner().withArguments("spotless:apply").runNoError(); + assertFile("json_test.json").sameAsResource("json/patchObjectAfterReplaceString.json"); + } + + @Test + public void testFormatJson_JsonPatch_replaceWithObject() throws Exception { + writePomWithJsonSteps("[{\"op\":\"replace\",\"path\":\"/abc\",\"value\":{\"def\":\"ghi\"}}]"); + + setFile("json_test.json").toResource("json/patchObjectBefore.json"); + + mavenRunner().withArguments("spotless:apply").runNoError(); + assertFile("json_test.json").sameAsResource("json/patchObjectAfterReplaceWithObject.json"); + } } diff --git a/testlib/src/main/resources/json/patchObjectAfterReplaceString.json b/testlib/src/main/resources/json/patchObjectAfterReplaceString.json new file mode 100644 index 0000000000..1da41d5ac2 --- /dev/null +++ b/testlib/src/main/resources/json/patchObjectAfterReplaceString.json @@ -0,0 +1,11 @@ +{ + "abc": "ghi", + "obj": { + "arr": [ + 1, + 2, + 3 + ], + "val": 5 + } +} diff --git a/testlib/src/main/resources/json/patchObjectAfterReplaceWithObject.json b/testlib/src/main/resources/json/patchObjectAfterReplaceWithObject.json new file mode 100644 index 0000000000..533691261c --- /dev/null +++ b/testlib/src/main/resources/json/patchObjectAfterReplaceWithObject.json @@ -0,0 +1,13 @@ +{ + "abc": { + "def": "ghi" + }, + "obj": { + "arr": [ + 1, + 2, + 3 + ], + "val": 5 + } +} diff --git a/testlib/src/main/resources/json/patchObjectBefore.json b/testlib/src/main/resources/json/patchObjectBefore.json new file mode 100644 index 0000000000..070dfc481e --- /dev/null +++ b/testlib/src/main/resources/json/patchObjectBefore.json @@ -0,0 +1,11 @@ +{ + "abc": "def", + "obj": { + "arr": [ + 1, + 2, + 3 + ], + "val": 5 + } +}