Open prataprc opened 2 years ago
Json currently does not implement Hash. Given that it's internally sorted, from what I understand, I added this impl.
impl Hash for Json{
fn hash<H: Hasher>(&self, state: &mut H) {
self.to_string().hash(state);
}
}
Under what circumstances would two semantically equal JSON documents produce different hashes using this approach?
to_string
is part of ToString trait, which in turn is consumed by fmt::Display, which is meant for human consumption of data. So we cannot make any guarantees on the output of ToString, it might change later.
Values in jsondata::Json should not change in its hash value for any given hashing algorithm. Also the serialized form of jsondata::Json should not affect its hash value for any give hashing algorithm.
List of common hashing algorithm:
fasthash::city fasthash::murmur3 SHA1