34std::size_t
hash(
const BasicJsonType& j)
36 using string_t =
typename BasicJsonType::string_t;
37 using number_integer_t =
typename BasicJsonType::number_integer_t;
38 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
39 using number_float_t =
typename BasicJsonType::number_float_t;
41 const auto type =
static_cast<std::size_t
>(j.type());
44 case BasicJsonType::value_t::null:
45 case BasicJsonType::value_t::discarded:
47 return combine(type, 0);
50 case BasicJsonType::value_t::object:
52 auto seed = combine(type, j.size());
53 for (
const auto& element : j.items())
55 const auto h = std::hash<string_t> {}(element.key());
56 seed = combine(seed, h);
57 seed = combine(seed,
hash(element.value()));
62 case BasicJsonType::value_t::array:
64 auto seed = combine(type, j.size());
65 for (
const auto& element : j)
67 seed = combine(seed,
hash(element));
72 case BasicJsonType::value_t::string:
74 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
75 return combine(type, h);
78 case BasicJsonType::value_t::boolean:
80 const auto h = std::hash<bool> {}(j.template get<bool>());
81 return combine(type, h);
84 case BasicJsonType::value_t::number_integer:
86 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
87 return combine(type, h);
90 case BasicJsonType::value_t::number_unsigned:
92 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
93 return combine(type, h);
96 case BasicJsonType::value_t::number_float:
98 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
99 return combine(type, h);
102 case BasicJsonType::value_t::binary:
104 auto seed = combine(type, j.get_binary().size());
105 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
106 seed = combine(seed, h);
107 seed = combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
108 for (
const auto byte : j.get_binary())
110 seed = combine(seed, std::hash<std::uint8_t> {}(byte));