Skip to content

Serializer for producing json diffs between two versions of the same object #89

@Kantis

Description

@Kantis

From discussions in in the Kotlin serialization slack channel..

Some APIs offer / require use of PATCH inputs, where you send a PATCH request of the fields you want to change. It could be convenient if we could produce such a delta, given two instances of an object.

data class Bar(val baz: String, val b: Int)
data class Foo(val x: Int, val y: String, val z: Bar)

val first = Foo(5, "y", Bar("a", 10)) 
val second = Foo(6, "y", Bar("b", 10))

Given the above, we want to produce the json

{
  "x": 6,
  "z": {
    "baz": "b"
  }
}

I'm not entirely sure how/if we could achieve it with regular serializers to be honest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions