How to create a JSON string which only contains the changed values?
I want to minimize the amount of JSON data transferred. Let's say I have a class with 100 key/value pairs and then I change one of these and want to transfer that change, and nothing but that change, not the 99 un开发者_如何转开发changed ones.
Is there a java lib for making such a patch or diff?
You have to compare the new values with the old values and then create the JSON. So a pseudocode is:
for each entry in old values
find entry key in new values
if new value != old value
put this into list of modified entries
end for
convert modified entries to JSON
Really nothing complicated.
精彩评论