json-rust
json-rust copied to clipboard
`Hash` implementation
I need to organize JsonValue
s into a HashSet
however I just noticed that JsonValue
does not implement the Hash
trait. Is there a reason for that?
Going deeper, I see that Object
is implemented as a Binary tree, so there is a defined order between the keys of an object. Then I see no reason why it would not be possible to define an order between every JSON value? And a Hash?
The keys are sorted into a tree, but the tree will be balanced differently depending on insertion order, so hashes would differ. If you are fine with matching objects with keys at insertion order then adding Hash impl should be pretty straight forward (at least in the new implementation, which is much cleaner, though still quite a bit in flux).
When can we expect this new implementation to be released? Can we follow its development somewhere?
Even if Object
does not have a defined order, it is still possible to create a Hash
implementation for it.
See https://github.com/rust-lang/rust/pull/48366 for an implementation of Hash on an unordered data structure.