You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 classBar(valbaz:String, valb:Int)
data classFoo(valx:Int, valy:String, valz: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.
The text was updated successfully, but these errors were encountered:
I'm curious about what this is exactly about, could you add some more details to your top post? Like, where do the old and new object instances come from?
Interesting, but probably a bit out-of-scope. Anyway, maybe we could have a built-in class similar to
data class Diff<T>(
val before: T,
val after: T
)
that, when serialized, only serializes the fields that differ in after from before. The challenge probably is to implement this without the use of reflection... I was thinking whether there's a trick to leverage the built-in string representation of the data class, but that idea was not getting me ahead.
Oh, neat idea! I think if we use the default serializer to serialize both before and after to json-trees, then we could traverse and compare them in a JsonTransformingSerializer before emitting the final json..
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.
Given the above, we want to produce the json
I'm not entirely sure how/if we could achieve it with regular serializers to be honest.
The text was updated successfully, but these errors were encountered: