From e98d095b50489d1cbecf59bf0065a35777af73cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kov=C3=A1cs=20Zolt=C3=A1n?=
Date: Sun, 23 Nov 2025 00:58:20 +0100
Subject: [PATCH 1/2] Jackson 3 upgrade
---
build.gradle | 282 ++++++------------
gradle/wrapper/gradle-wrapper.properties | 2 +-
gradlew.bat | 200 ++++++-------
.../github/fge/jsonpatch/AddOperation.java | 8 +-
.../github/fge/jsonpatch/CopyOperation.java | 2 +-
.../fge/jsonpatch/DualPathOperation.java | 28 +-
.../com/github/fge/jsonpatch/JsonPatch.java | 22 +-
.../fge/jsonpatch/JsonPatchOperation.java | 6 +-
.../github/fge/jsonpatch/MoveOperation.java | 2 +-
.../java/com/github/fge/jsonpatch/Patch.java | 2 +-
.../fge/jsonpatch/PathValueOperation.java | 28 +-
.../github/fge/jsonpatch/RemoveOperation.java | 30 +-
.../fge/jsonpatch/ReplaceOperation.java | 6 +-
.../github/fge/jsonpatch/TestOperation.java | 2 +-
.../fge/jsonpatch/diff/DiffOperation.java | 2 +-
.../fge/jsonpatch/diff/DiffProcessor.java | 2 +-
.../github/fge/jsonpatch/diff/JsonDiff.java | 46 +--
.../jsonpatch/mergepatch/JsonMergePatch.java | 17 +-
.../JsonMergePatchDeserializer.java | 47 ++-
.../mergepatch/NonObjectMergePatch.java | 20 +-
.../mergepatch/ObjectMergePatch.java | 30 +-
.../github/fge/jsonpatch/package-info.java | 2 +-
.../fge/jsonpatch/JsonPatchOperationTest.java | 12 +-
.../github/fge/jsonpatch/JsonPatchTest.java | 14 +-
.../fge/jsonpatch/JsonPatchTestSuite.java | 6 +-
.../fge/jsonpatch/RemoveOperationTest.java | 2 +-
.../fge/jsonpatch/diff/JsonDiffTest.java | 8 +-
.../fge/jsonpatch/diff/UnchangedTest.java | 23 +-
.../mergepatch/NonObjectMergePatchTest.java | 8 +-
.../mergepatch/ObjectMergePatchTest.java | 8 +-
.../mergepatch/SerializationTest.java | 10 +-
.../JsonPatchOperationSerializationTest.java | 8 +-
32 files changed, 379 insertions(+), 506 deletions(-)
diff --git a/build.gradle b/build.gradle
index 8ffa1a34..d5f9a180 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,233 +17,125 @@
* - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
*/
-buildscript {
- repositories {
- mavenCentral()
- maven {
- url "http://repo.springsource.org/plugins-release";
- }
- }
- dependencies {
- classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:4.2.0'
- classpath(group: "org.springframework.build.gradle", name: "propdeps-plugin", version: "0.0.7");
- }
-};
-
plugins {
- id("net.ltgt.errorprone") version "0.8.1" apply false
-}
-
-configure(allprojects) {
- apply(plugin: "propdeps");
- apply(plugin: "propdeps-maven");
- apply(plugin: "propdeps-idea");
- apply(plugin: "propdeps-eclipse");
+ id "java-library"
+ id "maven-publish"
+ id "signing"
+ id "idea"
+ id "eclipse"
+ id "com.github.ben-manes.versions" version "0.51.0"
}
-apply(plugin: "java");
-apply(plugin: "maven");
-apply(plugin: "signing");
-apply(plugin: "biz.aQute.bnd.builder");
-apply(plugin: "idea");
-apply(plugin: "eclipse");
-apply(plugin: "net.ltgt.errorprone");
-
-apply(from: "project.gradle");
+group = "com.github.java-json-tools"
+version = "1.14-SNAPSHOT"
+description = "JSON Patch (RFC 6902) and JSON Merge Patch (RFC 7386) implementation in Java"
-group = "com.github.java-json-tools";
-
-ext.forRelease = !version.endsWith("-SNAPSHOT");
+java {
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
+ withSourcesJar()
+ withJavadocJar()
+}
-/*
- * Repositories to use
- */
repositories {
- mavenCentral();
- if (!forRelease) {
- maven {
- url "https://oss.sonatype.org/content/repositories/snapshots"
- }
- }
- /* Allow staging references for last pre-release testing. */
- if (project.properties.containsKey("sonatypeUsername")) {
- maven {
- url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
- credentials {
- username = project.properties["sonatypeUsername"]
- password = project.properties["sonatypePassword"]
- }
- }
- }
+ mavenLocal()
+ mavenCentral()
}
-/*
- * Add errorprone checking.
- */
dependencies {
- errorprone("com.google.errorprone:error_prone_core:2.3.3")
- errorproneJavac("com.google.errorprone:javac:9+181-r4173-1")
+ api "com.github.java-json-tools:jackson-coreutils:2.0-SNAPSHOT"
+ api "com.github.java-json-tools:msg-simple:1.2"
+ api "com.google.code.findbugs:jsr305:3.0.2"
+
+ testImplementation "org.testng:testng:7.9.0"
+ testImplementation "org.assertj:assertj-core:3.25.3"
+ testImplementation "org.mockito:mockito-core:5.11.0"
}
-/*
- * Necessary! Otherwise TestNG will not be used...
- *
- */
test {
- useTestNG() {
- useDefaultListeners = true;
- };
-}
-
-/*
- * Necessary to generate the source and javadoc jars
- */
-task sourcesJar(type: Jar, dependsOn: classes) {
- classifier = "sources";
- from sourceSets.main.allSource;
-}
-
-/*
- * Lint all the things!
- */
-allprojects {
- gradle.projectsEvaluated {
- tasks.withType(JavaCompile) {
- options.compilerArgs << "-Xlint:all" << "-Xlint:-serial" << "-Werror"
- }
- tasks.withType(Javadoc) {
- options.addStringOption('Xwerror', '-quiet')
- }
+ useTestNG()
+ testLogging {
+ events "passed", "skipped", "failed"
+ exceptionFormat = "full"
}
}
-/*
- * Javadoc: we need to tell where the overview.html is, it will not pick it up
- * automatically...
- */
-
-//javadoc {
-// options.overview = "src/main/java/overview.html";
-//}
-
-task javadocJar(type: Jar, dependsOn: javadoc) {
- classifier = "javadoc";
- from javadoc.destinationDir;
+javadoc {
+ options.links("https://docs.oracle.com/en/java/javase/17/docs/api/")
}
-artifacts {
- archives jar;
- archives sourcesJar;
- archives javadocJar;
+task testJar(type: Jar) {
+ archiveClassifier = "tests"
+ from sourceSets.test.output
}
-wrapper {
- gradleVersion = "5.6.3";
- distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip";
+configurations {
+ tests
}
-task pom {
- doLast {
- pom {}.writeTo("${projectDir}/pom.xml");
- }
+artifacts {
+ tests testJar
}
-/*
- * SIGNING
- */
-
-project.ext {
- scmUrl = sprintf("git@github.com:java-json-tools/%s.git", name);
- projectURL = sprintf("https://github.com/java-json-tools/%s", name);
- sonatypeStaging = "https://oss.sonatype.org/service/local/staging/deploy/maven2/";
- sonatypeSnapshots = "https://oss.sonatype.org/content/repositories/snapshots/";
-};
-
-task checkSigningRequirements {
- doLast {
- def requiredProperties = [ "sonatypeUsername", "sonatypePassword" ];
- def noDice = false;
- requiredProperties.each {
- if (project.properties[it] == null) {
- noDice = true;
- System.err.printf("property \"%s\" is not defined!\n", it);
+publishing {
+ publications {
+ mavenJava(MavenPublication) {
+ from components.java
+
+ artifact testJar
+
+ pom {
+ name = "JSON Patch"
+ description = "JSON Patch (RFC 6902) and JSON Merge Patch (RFC 7386) implementation in Java"
+ url = "https://github.com/java-json-tools/json-patch"
+
+ licenses {
+ license {
+ name = "Lesser General Public License, version 3 or greater"
+ url = "http://www.gnu.org/licenses/lgpl.html"
+ distribution = "repo"
+ }
+ license {
+ name = "Apache Software License, version 2.0"
+ url = "http://www.apache.org/licenses/LICENSE-2.0"
+ distribution = "repo"
+ }
+ }
+
+ scm {
+ url = "https://github.com/java-json-tools/json-patch"
+ connection = "scm:git:git://github.com/java-json-tools/json-patch"
+ developerConnection = "scm:git:git@github.com:java-json-tools/json-patch"
+ }
+
+ developers {
+ developer {
+ id = "fge"
+ name = "Francis Galiegue"
+ email = "fgaliegue@gmail.com"
+ }
+ }
}
}
- if (noDice)
- throw new IllegalStateException("missing required properties for " +
- "upload");
}
-}
-
-uploadArchives {
- dependsOn(checkSigningRequirements);
+
repositories {
- mavenDeployer {
- beforeDeployment {
- MavenDeployment deployment -> signing.signPom(deployment);
- }
-
- repository(url: "${sonatypeStaging}") {
- authentication(
- userName: project.properties["sonatypeUsername"],
- password: project.properties["sonatypePassword"]
- );
- }
-
- snapshotRepository(url: "${sonatypeSnapshots}") {
- authentication(
- userName: project.properties["sonatypeUsername"],
- password: project.properties["sonatypePassword"]
- );
- }
- }
- }
-}
-
-/*
- * Configure pom.xml on install, uploadArchives
- */
-[
- install.repositories.mavenInstaller,
- uploadArchives.repositories.mavenDeployer
-]*.pom*.whenConfigured { pom ->
- pom.project {
- name "${project.name}";
- packaging "jar";
- description "${project.ext.description}";
- url "${projectURL}";
-
- scm {
- url "${scmUrl}";
- connection "${scmUrl}";
- developerConnection "scm:git:${scmUrl}";
- }
-
- licenses {
- license {
- name "Lesser General Public License, version 3 or greater";
- url "http://www.gnu.org/licenses/lgpl.html";
- distribution "repo";
- };
- license {
- name "Apache Software License, version 2.0";
- url "http://www.apache.org/licenses/LICENSE-2.0";
- distribution "repo";
- }
- }
-
- developers {
- developer {
- id "huggsboson";
- name "John Huffaker";
- email "jhuffaker+java-json-tools@gmail.com";
+ maven {
+ def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
+ def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
+ url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
+
+ credentials {
+ username = project.hasProperty('ossrhUsername') ? ossrhUsername : "N/A"
+ password = project.hasProperty('ossrhPassword') ? ossrhPassword : "N/A"
}
}
}
}
signing {
- required { forRelease && gradle.taskGraph.hasTask("uploadArchives") };
- sign configurations.archives;
+ required { gradle.taskGraph.hasTask("publish") }
+ sign publishing.publications.mavenJava
}
+
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 3a54a333..e69d0402 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew.bat b/gradlew.bat
index 24467a14..9618d8d9 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,100 +1,100 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem https://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/src/main/java/com/github/fge/jsonpatch/AddOperation.java b/src/main/java/com/github/fge/jsonpatch/AddOperation.java
index 5e5fb57a..2aa30406 100644
--- a/src/main/java/com/github/fge/jsonpatch/AddOperation.java
+++ b/src/main/java/com/github/fge/jsonpatch/AddOperation.java
@@ -21,9 +21,9 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
+import tools.jackson.databind.JsonNode;
+import tools.jackson.databind.node.ArrayNode;
+import tools.jackson.databind.node.ObjectNode;
import com.github.fge.jackson.jsonpointer.JsonPointer;
import com.github.fge.jackson.jsonpointer.ReferenceToken;
import com.github.fge.jackson.jsonpointer.TokenResolver;
@@ -93,7 +93,7 @@ public JsonNode apply(final JsonNode node)
if (parentNode.isMissingNode())
throw new JsonPatchException(BUNDLE.getMessage(
"jsonPatch.noSuchParent"));
- if (!parentNode.isContainerNode())
+ if (!parentNode.isContainer())
throw new JsonPatchException(BUNDLE.getMessage(
"jsonPatch.parentNotContainer"));
return parentNode.isArray()
diff --git a/src/main/java/com/github/fge/jsonpatch/CopyOperation.java b/src/main/java/com/github/fge/jsonpatch/CopyOperation.java
index 9a5a75b9..9c054911 100644
--- a/src/main/java/com/github/fge/jsonpatch/CopyOperation.java
+++ b/src/main/java/com/github/fge/jsonpatch/CopyOperation.java
@@ -21,7 +21,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.JsonNode;
+import tools.jackson.databind.JsonNode;
import com.github.fge.jackson.jsonpointer.JsonPointer;
/**
diff --git a/src/main/java/com/github/fge/jsonpatch/DualPathOperation.java b/src/main/java/com/github/fge/jsonpatch/DualPathOperation.java
index 91455bb4..132e268f 100644
--- a/src/main/java/com/github/fge/jsonpatch/DualPathOperation.java
+++ b/src/main/java/com/github/fge/jsonpatch/DualPathOperation.java
@@ -19,12 +19,12 @@
package com.github.fge.jsonpatch;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
-import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.JacksonException;
+import tools.jackson.databind.SerializationContext;
+import tools.jackson.databind.annotation.JsonSerialize;
+import tools.jackson.databind.jsontype.TypeSerializer;
+import tools.jackson.databind.ser.std.ToStringSerializer;
import com.github.fge.jackson.jsonpointer.JsonPointer;
import java.io.IOException;
@@ -54,22 +54,22 @@ protected DualPathOperation(final String op, final JsonPointer from,
@Override
public final void serialize(final JsonGenerator jgen,
- final SerializerProvider provider)
- throws IOException, JsonProcessingException
+ final SerializationContext context)
+ throws JacksonException
{
jgen.writeStartObject();
- jgen.writeStringField("op", op);
- jgen.writeStringField("path", path.toString());
- jgen.writeStringField("from", from.toString());
+ jgen.writeStringProperty("op", op);
+ jgen.writeStringProperty("path", path.toString());
+ jgen.writeStringProperty("from", from.toString());
jgen.writeEndObject();
}
@Override
public final void serializeWithType(final JsonGenerator jgen,
- final SerializerProvider provider, final TypeSerializer typeSer)
- throws IOException, JsonProcessingException
+ final SerializationContext context, final TypeSerializer typeSer)
+ throws JacksonException
{
- serialize(jgen, provider);
+ serialize(jgen, context);
}
public final JsonPointer getFrom() {
diff --git a/src/main/java/com/github/fge/jsonpatch/JsonPatch.java b/src/main/java/com/github/fge/jsonpatch/JsonPatch.java
index b41ed6bb..dd38a4c4 100644
--- a/src/main/java/com/github/fge/jsonpatch/JsonPatch.java
+++ b/src/main/java/com/github/fge/jsonpatch/JsonPatch.java
@@ -20,11 +20,11 @@
package com.github.fge.jsonpatch;
import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.JsonSerializable;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.databind.JsonNode;
+import tools.jackson.databind.JacksonSerializable;
+import tools.jackson.databind.SerializationContext;
+import tools.jackson.databind.jsontype.TypeSerializer;
import com.github.fge.jackson.JacksonUtils;
import com.github.fge.msgsimple.bundle.MessageBundle;
import com.github.fge.msgsimple.load.MessageBundles;
@@ -91,7 +91,7 @@
* constructor for this class ({@link JsonPatch#fromJson(JsonNode)} is used.
*/
public final class JsonPatch
- implements JsonSerializable, Patch
+ implements JacksonSerializable, Patch
{
private static final MessageBundle BUNDLE
= MessageBundles.getBundle(JsonPatchMessages.class);
@@ -163,20 +163,18 @@ public String toString()
@Override
public void serialize(final JsonGenerator jgen,
- final SerializerProvider provider)
- throws IOException
+ final SerializationContext context)
{
jgen.writeStartArray();
for (final JsonPatchOperation op: operations)
- op.serialize(jgen, provider);
+ op.serialize(jgen, context);
jgen.writeEndArray();
}
@Override
public void serializeWithType(final JsonGenerator jgen,
- final SerializerProvider provider, final TypeSerializer typeSer)
- throws IOException
+ final SerializationContext context, final TypeSerializer typeSer)
{
- serialize(jgen, provider);
+ serialize(jgen, context);
}
}
diff --git a/src/main/java/com/github/fge/jsonpatch/JsonPatchOperation.java b/src/main/java/com/github/fge/jsonpatch/JsonPatchOperation.java
index 06a6a62d..156190f5 100644
--- a/src/main/java/com/github/fge/jsonpatch/JsonPatchOperation.java
+++ b/src/main/java/com/github/fge/jsonpatch/JsonPatchOperation.java
@@ -22,8 +22,8 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.JsonSerializable;
+import tools.jackson.databind.JsonNode;
+import tools.jackson.databind.JacksonSerializable;
import com.github.fge.jackson.jsonpointer.JsonPointer;
import com.github.fge.msgsimple.bundle.MessageBundle;
import com.github.fge.msgsimple.load.MessageBundles;
@@ -57,7 +57,7 @@
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public abstract class JsonPatchOperation
- implements JsonSerializable
+ implements JacksonSerializable
{
protected static final MessageBundle BUNDLE
= MessageBundles.getBundle(JsonPatchMessages.class);
diff --git a/src/main/java/com/github/fge/jsonpatch/MoveOperation.java b/src/main/java/com/github/fge/jsonpatch/MoveOperation.java
index 405b737c..fc3fd0ac 100644
--- a/src/main/java/com/github/fge/jsonpatch/MoveOperation.java
+++ b/src/main/java/com/github/fge/jsonpatch/MoveOperation.java
@@ -21,7 +21,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.JsonNode;
+import tools.jackson.databind.JsonNode;
import com.github.fge.jackson.jsonpointer.JsonPointer;
/**
diff --git a/src/main/java/com/github/fge/jsonpatch/Patch.java b/src/main/java/com/github/fge/jsonpatch/Patch.java
index adce2042..0a37990b 100644
--- a/src/main/java/com/github/fge/jsonpatch/Patch.java
+++ b/src/main/java/com/github/fge/jsonpatch/Patch.java
@@ -1,6 +1,6 @@
package com.github.fge.jsonpatch;
-import com.fasterxml.jackson.databind.JsonNode;
+import tools.jackson.databind.JsonNode;
public interface Patch {
diff --git a/src/main/java/com/github/fge/jsonpatch/PathValueOperation.java b/src/main/java/com/github/fge/jsonpatch/PathValueOperation.java
index 523ea662..d344e523 100644
--- a/src/main/java/com/github/fge/jsonpatch/PathValueOperation.java
+++ b/src/main/java/com/github/fge/jsonpatch/PathValueOperation.java
@@ -19,12 +19,12 @@
package com.github.fge.jsonpatch;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.JacksonException;
+import tools.jackson.databind.JsonNode;
+import tools.jackson.databind.SerializationContext;
+import tools.jackson.databind.annotation.JsonSerialize;
+import tools.jackson.databind.jsontype.TypeSerializer;
import com.github.fge.jackson.jsonpointer.JsonPointer;
import java.io.IOException;
@@ -54,23 +54,23 @@ protected PathValueOperation(final String op, final JsonPointer path,
@Override
public final void serialize(final JsonGenerator jgen,
- final SerializerProvider provider)
- throws IOException, JsonProcessingException
+ final SerializationContext context)
+ throws JacksonException
{
jgen.writeStartObject();
- jgen.writeStringField("op", op);
- jgen.writeStringField("path", path.toString());
- jgen.writeFieldName("value");
+ jgen.writeStringProperty("op", op);
+ jgen.writeStringProperty("path", path.toString());
+ jgen.writeName("value");
jgen.writeTree(value);
jgen.writeEndObject();
}
@Override
public final void serializeWithType(final JsonGenerator jgen,
- final SerializerProvider provider, final TypeSerializer typeSer)
- throws IOException, JsonProcessingException
+ final SerializationContext context, final TypeSerializer typeSer)
+ throws JacksonException
{
- serialize(jgen, provider);
+ serialize(jgen, context);
}
public final JsonNode getValue() {
diff --git a/src/main/java/com/github/fge/jsonpatch/RemoveOperation.java b/src/main/java/com/github/fge/jsonpatch/RemoveOperation.java
index 4c528baa..19a8f9c5 100644
--- a/src/main/java/com/github/fge/jsonpatch/RemoveOperation.java
+++ b/src/main/java/com/github/fge/jsonpatch/RemoveOperation.java
@@ -21,14 +21,14 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.MissingNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.JacksonException;
+import tools.jackson.databind.JsonNode;
+import tools.jackson.databind.SerializationContext;
+import tools.jackson.databind.jsontype.TypeSerializer;
+import tools.jackson.databind.node.ArrayNode;
+import tools.jackson.databind.node.MissingNode;
+import tools.jackson.databind.node.ObjectNode;
import com.github.fge.jackson.jsonpointer.JsonPointer;
import java.io.IOException;
@@ -69,21 +69,21 @@ public JsonNode apply(final JsonNode node)
@Override
public void serialize(final JsonGenerator jgen,
- final SerializerProvider provider)
- throws IOException, JsonProcessingException
+ final SerializationContext context)
+ throws JacksonException
{
jgen.writeStartObject();
- jgen.writeStringField("op", "remove");
- jgen.writeStringField("path", path.toString());
+ jgen.writeStringProperty("op", "remove");
+ jgen.writeStringProperty("path", path.toString());
jgen.writeEndObject();
}
@Override
public void serializeWithType(final JsonGenerator jgen,
- final SerializerProvider provider, final TypeSerializer typeSer)
- throws IOException, JsonProcessingException
+ final SerializationContext context, final TypeSerializer typeSer)
+ throws JacksonException
{
- serialize(jgen, provider);
+ serialize(jgen, context);
}
@Override
diff --git a/src/main/java/com/github/fge/jsonpatch/ReplaceOperation.java b/src/main/java/com/github/fge/jsonpatch/ReplaceOperation.java
index d4454bdb..0343256b 100644
--- a/src/main/java/com/github/fge/jsonpatch/ReplaceOperation.java
+++ b/src/main/java/com/github/fge/jsonpatch/ReplaceOperation.java
@@ -21,9 +21,9 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
+import tools.jackson.databind.JsonNode;
+import tools.jackson.databind.node.ArrayNode;
+import tools.jackson.databind.node.ObjectNode;
import com.github.fge.jackson.jsonpointer.JsonPointer;
/**
diff --git a/src/main/java/com/github/fge/jsonpatch/TestOperation.java b/src/main/java/com/github/fge/jsonpatch/TestOperation.java
index 90f03401..b2c793f3 100644
--- a/src/main/java/com/github/fge/jsonpatch/TestOperation.java
+++ b/src/main/java/com/github/fge/jsonpatch/TestOperation.java
@@ -21,7 +21,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.JsonNode;
+import tools.jackson.databind.JsonNode;
import com.github.fge.jackson.JsonNumEquals;
import com.github.fge.jackson.jsonpointer.JsonPointer;
diff --git a/src/main/java/com/github/fge/jsonpatch/diff/DiffOperation.java b/src/main/java/com/github/fge/jsonpatch/diff/DiffOperation.java
index fac687fd..0d1abe8d 100644
--- a/src/main/java/com/github/fge/jsonpatch/diff/DiffOperation.java
+++ b/src/main/java/com/github/fge/jsonpatch/diff/DiffOperation.java
@@ -19,7 +19,7 @@
package com.github.fge.jsonpatch.diff;
-import com.fasterxml.jackson.databind.JsonNode;
+import tools.jackson.databind.JsonNode;
import com.github.fge.jackson.jsonpointer.JsonPointer;
import com.github.fge.jsonpatch.AddOperation;
import com.github.fge.jsonpatch.CopyOperation;
diff --git a/src/main/java/com/github/fge/jsonpatch/diff/DiffProcessor.java b/src/main/java/com/github/fge/jsonpatch/diff/DiffProcessor.java
index 299d29a1..e2dec77c 100644
--- a/src/main/java/com/github/fge/jsonpatch/diff/DiffProcessor.java
+++ b/src/main/java/com/github/fge/jsonpatch/diff/DiffProcessor.java
@@ -19,7 +19,7 @@
package com.github.fge.jsonpatch.diff;
-import com.fasterxml.jackson.databind.JsonNode;
+import tools.jackson.databind.JsonNode;
import com.github.fge.jackson.JsonNumEquals;
import com.github.fge.jackson.jsonpointer.JsonPointer;
import com.github.fge.jsonpatch.JsonPatch;
diff --git a/src/main/java/com/github/fge/jsonpatch/diff/JsonDiff.java b/src/main/java/com/github/fge/jsonpatch/diff/JsonDiff.java
index 302a79c2..40d7ede3 100644
--- a/src/main/java/com/github/fge/jsonpatch/diff/JsonDiff.java
+++ b/src/main/java/com/github/fge/jsonpatch/diff/JsonDiff.java
@@ -19,10 +19,10 @@
package com.github.fge.jsonpatch.diff;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
+import tools.jackson.databind.JsonNode;
+import tools.jackson.databind.ObjectMapper;
+import tools.jackson.databind.node.ArrayNode;
+import tools.jackson.databind.node.ObjectNode;
import com.github.fge.jackson.JacksonUtils;
import com.github.fge.jackson.JsonNumEquals;
import com.github.fge.jackson.NodeType;
@@ -108,7 +108,7 @@ public static JsonNode asJson(final JsonNode source, final JsonNode target)
try {
s = MAPPER.writeValueAsString(asJsonPatch(source, target));
return MAPPER.readTree(s);
- } catch (IOException e) {
+ } catch (Exception e) {
throw new RuntimeException("cannot generate JSON diff", e);
}
}
@@ -136,7 +136,7 @@ private static void generateDiffs(final DiffProcessor processor,
*
* If this is not a container, generate a replace operation.
*/
- if (!source.isContainerNode()) {
+ if (!source.isContainer()) {
processor.valueReplaced(pointer, source, target);
return;
}
@@ -157,10 +157,9 @@ private static void generateObjectDiffs(final DiffProcessor processor,
final JsonPointer pointer, final ObjectNode source,
final ObjectNode target)
{
- final Set firstFields
- = collect(source.fieldNames(), new TreeSet());
- final Set secondFields
- = collect(target.fieldNames(), new TreeSet());
+ final Set firstFields = Collections.unmodifiableSet(new TreeSet<>(source.propertyNames()));
+
+ final Set secondFields = Collections.unmodifiableSet(new TreeSet<>(target.propertyNames()));
final Set copy1 = new HashSet(firstFields);
copy1.removeAll(secondFields);
@@ -183,21 +182,6 @@ private static void generateObjectDiffs(final DiffProcessor processor,
target.get(field));
}
- private static Set collect(Iterator from, Set to) {
- if (from == null) {
- throw new NullPointerException();
- }
- if (to == null) {
- throw new NullPointerException();
- }
- while (from.hasNext()) {
- to.add(from.next());
- }
- return Collections.unmodifiableSet(to);
- }
-
-
-
private static void generateArrayDiffs(final DiffProcessor processor,
final JsonPointer pointer, final ArrayNode source,
final ArrayNode target)
@@ -263,16 +247,12 @@ private static void computeObject(final Map ret,
final JsonPointer pointer, final JsonNode source,
final JsonNode target)
{
- final Iterator firstFields = source.fieldNames();
-
- String name;
-
- while (firstFields.hasNext()) {
- name = firstFields.next();
+
+ for (String name : source.propertyNames()) {
if (!target.has(name))
continue;
- computeUnchanged(ret, pointer.append(name), source.get(name),
- target.get(name));
+ computeUnchanged(ret, pointer.append(name), source.get(name),
+ target.get(name));
}
}
diff --git a/src/main/java/com/github/fge/jsonpatch/mergepatch/JsonMergePatch.java b/src/main/java/com/github/fge/jsonpatch/mergepatch/JsonMergePatch.java
index 0c5679fe..53bc2090 100644
--- a/src/main/java/com/github/fge/jsonpatch/mergepatch/JsonMergePatch.java
+++ b/src/main/java/com/github/fge/jsonpatch/mergepatch/JsonMergePatch.java
@@ -19,10 +19,10 @@
package com.github.fge.jsonpatch.mergepatch;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.JsonSerializable;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import tools.jackson.databind.JsonNode;
+import tools.jackson.databind.JacksonSerializable;
+import tools.jackson.databind.ObjectMapper;
+import tools.jackson.databind.annotation.JsonDeserialize;
import com.github.fge.jackson.JacksonUtils;
import com.github.fge.jsonpatch.JsonPatch;
import com.github.fge.jsonpatch.JsonPatchException;
@@ -33,6 +33,8 @@
import javax.annotation.ParametersAreNonnullByDefault;
import java.io.IOException;
+import tools.jackson.core.JacksonException;
+import tools.jackson.core.JsonParser;
/**
* Implementation of JSON Merge Patch (RFC 7386)
@@ -65,7 +67,7 @@
@ParametersAreNonnullByDefault
@JsonDeserialize(using = JsonMergePatchDeserializer.class)
public abstract class JsonMergePatch
- implements JsonSerializable, Patch
+ implements JacksonSerializable, Patch
{
private static final ObjectMapper MAPPER = JacksonUtils.newMapper();
protected static final MessageBundle BUNDLE
@@ -84,8 +86,9 @@ public static JsonMergePatch fromJson(final JsonNode node)
{
BUNDLE.checkNotNull(node, "jsonPatch.nullInput");
try {
- return MAPPER.readValue(node.traverse(), JsonMergePatch.class);
- } catch (IOException e) {
+ JsonParser parser = MAPPER.treeAsTokens(node);
+ return MAPPER.readValue(parser, JsonMergePatch.class);
+ } catch (JacksonException e) {
throw new JsonPatchException(
BUNDLE.getMessage("jsonPatch.deserFailed"), e);
}
diff --git a/src/main/java/com/github/fge/jsonpatch/mergepatch/JsonMergePatchDeserializer.java b/src/main/java/com/github/fge/jsonpatch/mergepatch/JsonMergePatchDeserializer.java
index 27b15d08..2a798a17 100644
--- a/src/main/java/com/github/fge/jsonpatch/mergepatch/JsonMergePatchDeserializer.java
+++ b/src/main/java/com/github/fge/jsonpatch/mergepatch/JsonMergePatchDeserializer.java
@@ -19,13 +19,13 @@
package com.github.fge.jsonpatch.mergepatch;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.ObjectCodec;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonDeserializer;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.NullNode;
+import tools.jackson.core.JsonParser;
+import tools.jackson.core.JacksonException;
+import tools.jackson.core.ObjectWriteContext;
+import tools.jackson.databind.DeserializationContext;
+import tools.jackson.databind.ValueDeserializer;
+import tools.jackson.databind.JsonNode;
+import tools.jackson.databind.node.NullNode;
import com.github.fge.jackson.JacksonUtils;
import java.io.IOException;
@@ -35,9 +35,11 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
+import tools.jackson.databind.ObjectMapper;
+import tools.jackson.databind.ObjectReader;
final class JsonMergePatchDeserializer
- extends JsonDeserializer
+ extends ValueDeserializer
{
/*
* FIXME! UGLY! HACK!
@@ -48,15 +50,14 @@ final class JsonMergePatchDeserializer
*
* Jackson does not do this automatically; I don't know why...
*/
- private static final ObjectCodec CODEC = JacksonUtils.newMapper();
+ private static final ObjectMapper CODEC = JacksonUtils.newMapper();
+ private static final ObjectReader READER = CODEC.readerFor(JsonMergePatch.class);
@Override
public JsonMergePatch deserialize(final JsonParser jp,
final DeserializationContext ctxt)
- throws IOException, JsonProcessingException
+ throws JacksonException
{
- // FIXME: see comment above
- jp.setCodec(CODEC);
final JsonNode node = jp.readValueAsTree();
/*
@@ -74,21 +75,16 @@ public JsonMergePatch deserialize(final JsonParser jp,
final Set removedMembers = new HashSet();
final Map modifiedMembers = new HashMap();
- final Iterator> iterator = node.fields();
-
- Map.Entry entry;
-
- while (iterator.hasNext()) {
- entry = iterator.next();
- if (entry.getValue().isNull())
- removedMembers.add(entry.getKey());
+
+ for (Map.Entry property: node.properties()) {
+ if (property.getValue().isNull())
+ removedMembers.add(property.getKey());
else {
- final JsonMergePatch value
- = deserialize(entry.getValue().traverse(), ctxt);
- modifiedMembers.put(entry.getKey(), value);
+ final JsonMergePatch value = READER.readValue(property.getValue());
+ modifiedMembers.put(property.getKey(), value);
}
}
-
+
return new ObjectMergePatch(removedMembers, modifiedMembers);
}
@@ -97,8 +93,7 @@ public JsonMergePatch deserialize(final JsonParser jp,
* not what we want.
*/
@Override
- @SuppressWarnings("deprecation")
- public JsonMergePatch getNullValue()
+ public JsonMergePatch getNullValue(DeserializationContext ctxt)
{
return new NonObjectMergePatch(NullNode.getInstance());
}
diff --git a/src/main/java/com/github/fge/jsonpatch/mergepatch/NonObjectMergePatch.java b/src/main/java/com/github/fge/jsonpatch/mergepatch/NonObjectMergePatch.java
index 9a1ae8c0..18ceec31 100644
--- a/src/main/java/com/github/fge/jsonpatch/mergepatch/NonObjectMergePatch.java
+++ b/src/main/java/com/github/fge/jsonpatch/mergepatch/NonObjectMergePatch.java
@@ -19,11 +19,11 @@
package com.github.fge.jsonpatch.mergepatch;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.JacksonException;
+import tools.jackson.databind.JsonNode;
+import tools.jackson.databind.SerializationContext;
+import tools.jackson.databind.jsontype.TypeSerializer;
import com.github.fge.jsonpatch.JsonPatchException;
import javax.annotation.ParametersAreNonnullByDefault;
@@ -53,17 +53,17 @@ public JsonNode apply(final JsonNode input)
@Override
public void serialize(final JsonGenerator jgen,
- final SerializerProvider provider)
- throws IOException, JsonProcessingException
+ final SerializationContext context)
+ throws JacksonException
{
jgen.writeTree(node);
}
@Override
public void serializeWithType(final JsonGenerator jgen,
- final SerializerProvider provider, final TypeSerializer typeSer)
- throws IOException, JsonProcessingException
+ final SerializationContext context, final TypeSerializer typeSer)
+ throws JacksonException
{
- serialize(jgen, provider);
+ serialize(jgen, context);
}
}
diff --git a/src/main/java/com/github/fge/jsonpatch/mergepatch/ObjectMergePatch.java b/src/main/java/com/github/fge/jsonpatch/mergepatch/ObjectMergePatch.java
index 009c3347..ac0b9b2b 100644
--- a/src/main/java/com/github/fge/jsonpatch/mergepatch/ObjectMergePatch.java
+++ b/src/main/java/com/github/fge/jsonpatch/mergepatch/ObjectMergePatch.java
@@ -19,13 +19,13 @@
package com.github.fge.jsonpatch.mergepatch;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
-import com.fasterxml.jackson.databind.node.NullNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.JacksonException;
+import tools.jackson.databind.JsonNode;
+import tools.jackson.databind.SerializationContext;
+import tools.jackson.databind.jsontype.TypeSerializer;
+import tools.jackson.databind.node.NullNode;
+import tools.jackson.databind.node.ObjectNode;
import com.github.fge.jackson.JacksonUtils;
import com.github.fge.jsonpatch.JsonPatchException;
@@ -94,8 +94,8 @@ public JsonNode apply(final JsonNode input)
@Override
public void serialize(final JsonGenerator jgen,
- final SerializerProvider provider)
- throws IOException, JsonProcessingException
+ final SerializationContext context)
+ throws JacksonException
{
jgen.writeStartObject();
@@ -103,15 +103,15 @@ public void serialize(final JsonGenerator jgen,
* Write removed members as JSON nulls
*/
for (final String member: removedMembers)
- jgen.writeNullField(member);
+ jgen.writeNullProperty(member);
/*
* Write modified members; delegate to serialization for writing values
*/
for (final Map.Entry entry:
modifiedMembers.entrySet()) {
- jgen.writeFieldName(entry.getKey());
- entry.getValue().serialize(jgen, provider);
+ jgen.writeName(entry.getKey());
+ entry.getValue().serialize(jgen, context);
}
jgen.writeEndObject();
@@ -119,9 +119,9 @@ public void serialize(final JsonGenerator jgen,
@Override
public void serializeWithType(final JsonGenerator jgen,
- final SerializerProvider provider, final TypeSerializer typeSer)
- throws IOException, JsonProcessingException
+ final SerializationContext context, final TypeSerializer typeSer)
+ throws JacksonException
{
- serialize(jgen, provider);
+ serialize(jgen, context);
}
}
diff --git a/src/main/java/com/github/fge/jsonpatch/package-info.java b/src/main/java/com/github/fge/jsonpatch/package-info.java
index 5fc338b7..f372622d 100644
--- a/src/main/java/com/github/fge/jsonpatch/package-info.java
+++ b/src/main/java/com/github/fge/jsonpatch/package-info.java
@@ -28,7 +28,7 @@
* The main class is {@link com.github.fge.jsonpatch.JsonPatch}.
*
* Note that at this moment, the only way to build a patch is from a JSON
- * representation (as a {@link com.fasterxml.jackson.databind.JsonNode}).
+ * representation (as a {@link tools.jackson.databind.JsonNode}).
*
*/
package com.github.fge.jsonpatch;
diff --git a/src/test/java/com/github/fge/jsonpatch/JsonPatchOperationTest.java b/src/test/java/com/github/fge/jsonpatch/JsonPatchOperationTest.java
index 5f04d811..69ed25eb 100644
--- a/src/test/java/com/github/fge/jsonpatch/JsonPatchOperationTest.java
+++ b/src/test/java/com/github/fge/jsonpatch/JsonPatchOperationTest.java
@@ -19,18 +19,18 @@
package com.github.fge.jsonpatch;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectReader;
+import tools.jackson.databind.JsonNode;
+import tools.jackson.databind.ObjectReader;
import com.github.fge.jackson.JacksonUtils;
import com.github.fge.jackson.JsonLoader;
import com.github.fge.jackson.JsonNumEquals;
import com.github.fge.msgsimple.bundle.MessageBundle;
import com.github.fge.msgsimple.load.MessageBundles;
-import com.google.common.collect.Lists;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -63,7 +63,7 @@ protected JsonPatchOperationTest(final String prefix)
public final Iterator