Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash implementation #177

Open
timothee-haudebourg opened this issue Mar 17, 2020 · 4 comments
Open

Hash implementation #177

timothee-haudebourg opened this issue Mar 17, 2020 · 4 comments

Comments

@timothee-haudebourg
Copy link

I need to organize JsonValues into a HashSet however I just noticed that JsonValue does not implement the Hash trait. Is there a reason for that?

@timothee-haudebourg
Copy link
Author

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?

@maciejhirsz
Copy link
Owner

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).

@timothee-haudebourg
Copy link
Author

When can we expect this new implementation to be released? Can we follow its development somewhere?

@A248
Copy link

A248 commented Jan 19, 2022

Even if Object does not have a defined order, it is still possible to create a Hash implementation for it.

See rust-lang/rust#48366 for an implementation of Hash on an unordered data structure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants