
Implements RFC 6902 JSON Patch, enabling JSON diff generation and patch application. Offers Kotlin extensions and uses `kotlinx.serialization.json` for convenient integration and usage.
It is based on the Apache 2.0 licensed library from Flipkart, zjsonpatch.
This project is a fork of KJsonPatch (with the latest commit referenced).
This code has been modified from the original library in the following ways:
kotlinx.serialization.json
kotlinx.serialization.json
Add the dependency to your app module’s build.gradle file:
repositories {
mavenCentral()
}
dependencies {
// e.g., implementation("io.github.reidsync:kotlin-json-patch:1.0.0")
implementation("io.github.reidsync:kotlin-json-patch:${kotliln_json_patch_version}")
}Check the kotlin-json-patch versions
latest version :
You can add the dependency to sourceSets.commonMain.dependecies for your Kotlin Multiplatform project.
kotlin {
sourceSets {
commonMain.dependencies {
//put your multiplatform dependencies here
implementation("io.github.reidsync:kotlin-json-patch:${kotliln_json_patch_version}")
}
}
}
The variables
source,target, andpatchbelow must be asserted as validJsonElementobjects.
val diff: JsonArray = JsonDiff.asJson(source: JsonElement, target: JsonElement)or
val diff: JsonElement = source.generatePatch(with: target)val result: JsonElement = JsonPatch.apply(patch: JsonElement, source: JsonElement)or
val result: JsonElement = source.apply(patch: patch)This operation is performed on a clone of the source object.
These changes mostly involve porting from Java to Kotlin to transform it into a pure Kotlin library that can be imported into Kotlin Multiplatform. If you have any specific preferences or further adjustments, feel free to let me know!
It is based on the Apache 2.0 licensed library from Flipkart, zjsonpatch.
This project is a fork of KJsonPatch (with the latest commit referenced).
This code has been modified from the original library in the following ways:
kotlinx.serialization.json
kotlinx.serialization.json
Add the dependency to your app module’s build.gradle file:
repositories {
mavenCentral()
}
dependencies {
// e.g., implementation("io.github.reidsync:kotlin-json-patch:1.0.0")
implementation("io.github.reidsync:kotlin-json-patch:${kotliln_json_patch_version}")
}Check the kotlin-json-patch versions
latest version :
You can add the dependency to sourceSets.commonMain.dependecies for your Kotlin Multiplatform project.
kotlin {
sourceSets {
commonMain.dependencies {
//put your multiplatform dependencies here
implementation("io.github.reidsync:kotlin-json-patch:${kotliln_json_patch_version}")
}
}
}
The variables
source,target, andpatchbelow must be asserted as validJsonElementobjects.
val diff: JsonArray = JsonDiff.asJson(source: JsonElement, target: JsonElement)or
val diff: JsonElement = source.generatePatch(with: target)val result: JsonElement = JsonPatch.apply(patch: JsonElement, source: JsonElement)or
val result: JsonElement = source.apply(patch: patch)This operation is performed on a clone of the source object.
These changes mostly involve porting from Java to Kotlin to transform it into a pure Kotlin library that can be imported into Kotlin Multiplatform. If you have any specific preferences or further adjustments, feel free to let me know!