josephburnett / jd

JSON diff and patch
MIT License
826 stars 38 forks source link

Ignore Rounding Errors #57

Closed briansorahan closed 6 months ago

briansorahan commented 1 year ago

Would be nice to have something like a -precision flag to ignore numeric differences less than some value. I looked through the issues to see if there was already a request for this but didn't see anything. Apologies if there was an oversight.

josephburnett commented 1 year ago

That's a great idea. Would be useful for floating point values (where the point is actually floating). Are you also thinking for integer values, like 1,000,000 and 1,000,001 are "close enough" with at precision of 1%? Do you have an example use case?

It would need to be part of the diff output so a patch can determine if it should apply. We could start with one flag for the whole diff. But we might want to specify a precision for a specific part of the structure. I've been thinking about a way to specify various parameters like set for parts of a structure rather than the whole thing.

josephburnett commented 6 months ago

@briansorahan @adatoo I've released this feature: https://github.com/josephburnett/jd/releases/tag/v1.8.0

josephburnett commented 6 months ago

Just needs to be added to the UI too: https://github.com/josephburnett/jd/issues/71