gson-deep-merge

Gson deep merge

License

License

Categories

Categories

Gson Data JSON
GroupId

GroupId

com.github.brymck
ArtifactId

ArtifactId

gson-deep-merge
Last Version

Last Version

0.9.0
Release Date

Release Date

Type

Type

jar
Description

Description

gson-deep-merge
Gson deep merge
Project URL

Project URL

https://github.com/brymck/gson-deep-merge
Source Code Management

Source Code Management

https://github.com/brymck/gson-deep-merge

Download gson-deep-merge

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.brymck/gson-deep-merge/ -->
<dependency>
    <groupId>com.github.brymck</groupId>
    <artifactId>gson-deep-merge</artifactId>
    <version>0.9.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.brymck/gson-deep-merge/
implementation 'com.github.brymck:gson-deep-merge:0.9.0'
// https://jarcasting.com/artifacts/com.github.brymck/gson-deep-merge/
implementation ("com.github.brymck:gson-deep-merge:0.9.0")
'com.github.brymck:gson-deep-merge:jar:0.9.0'
<dependency org="com.github.brymck" name="gson-deep-merge" rev="0.9.0">
  <artifact name="gson-deep-merge" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.brymck', module='gson-deep-merge', version='0.9.0')
)
libraryDependencies += "com.github.brymck" % "gson-deep-merge" % "0.9.0"
[com.github.brymck/gson-deep-merge "0.9.0"]

Dependencies

compile (2)

Group / Artifact Type Version
com.google.code.gson : gson jar 2.8.6
org.jetbrains : annotations jar 15.0

test (3)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.5.2
org.junit.jupiter : junit-jupiter-engine jar 5.5.2
org.junit.jupiter : junit-jupiter-params jar 5.5.2

Project Modules

There are no modules declared in this project.

gson-deep-merge

CircleCI codecov

gson-deep-merge is a library that allows deep merging of objects with Gson.

Usage

Include this in your POM:

<dependency>
  <groupId>com.github.brymck</groupId>
  <artifactId>gson-deep-merge</artifactId>
  <version>0.9.0</version>
</dependency>

And use it as so, given two instances original and update of class Example:

Gson gson = new Gson();
GsonDeepMerge gsonDeepMerge = new GsonDeepMerge();

Example merged = gsonDeepMerge.deepMerge(gson, original, update, Example.class);

One obvious use case for tools like Kotlin is to embed this in an extension function. For instance, given the above Example class:

// Extension implementation
private val gson = Gson()
private val gsonDeepMerge = GsonDeepMerge()

fun Example.deepMerge(other: Example): Example =
  gsonDeepMerge.deepMerge(gson, this, other, this::class.java)

// Usage
val foo = Example(foo = Foo())
val bar = Example(bar = Bar())
val fooBar = foo.deepMerge(bar);

Versions

Version
0.9.0