Description
The equals
implementation developed in #71 and #73 is a straightforward structural equality, and does good work in that context.
However, I occasionally find myself wishing there was an equality metric that accommodated JS-native semantics vis a vis numbers. The nit is that yojson always distinguishes between ints and floats, even if said floats have a zero fractional part, while JSON parsers in Javascript engines do not (e.g. JSON.parse("5.0")
⇒ 5
). So, it's easy to produce yojson structures that are not equal in the strict structural sense as currently implemented in equals
, but which are equal per JS semantics.
As things stand, the only generalized workaround is a rewrite of the yojson trees being compared with equal
to truncate any zero-fractional `Float
to its corresponding `Int
.
Any interest in adding this?