josephburnett / jd

JSON diff and patch
MIT License
1.62k stars 48 forks source link

Looking for a way to get only the changed values #17

Closed seiferteric closed 4 years ago

seiferteric commented 5 years ago

For my use case I was looking to use this library to get a json output with only the changed values between two inputs, but so far I have not been able to do so. Is there a way currently to do this? I tried applying the diff to an empty jsonNode object, but that does not work, also I looked for a way to iterate over each object recursively to do an Equals on each sub object to remove if they are equal, but can't seem to do that either.

josephburnett commented 5 years ago

a json output with only the changed values between two inputs

Can you give me an example? What should jd output when the changes are nested within several layers of structures?

I looked for a way to iterate over each object recursively to do an Equals on each sub object to remove if they are equal

When you call .Diff() on a JsonNode it will return a Diff which tells you which objects are different. Is the information you want within that?

It would be helpful to see a concrete input (two structures) and the information you wish you could get (hypothetical output). So I can understand better what you want to do with it.

seiferteric commented 4 years ago

Turns out I misread the requirement and don't need this functionality, thanks.