https://kotlinlang.org logo
#serialization
Title
# serialization
v

Vasyl Tretiakov

12/06/2023, 5:35 PM
Hi. I'm sorry if I didn't find a meaningful answer through the search. The challenge is to JSON serialize differences between two object instances for HTTP PATCH requests. Let old be
Copy code
{field1 : old, field2 : same, obj : {field1 : old, field2 : same}}
Let new be
Copy code
{field1 : new, field2 : same, obj : {field1 : new, field2 : same}}
Then new - old or new.diff(old) should be
Copy code
{field1 : new, obj : {field1 : new}}
I would appreciate a recommendation on the idiomatic implementation for this. P.S. This thread looks similar but it's 2 years old and without a conclusion. The only other vaguely relevant discussion on StackOverflow for Java is this one.