41std::size_t
hash(
const BasicJsonType& j)
43 using string_t =
typename BasicJsonType::string_t;
44 using number_integer_t =
typename BasicJsonType::number_integer_t;
45 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
46 using number_float_t =
typename BasicJsonType::number_float_t;
48 const auto type =
static_cast<std::size_t
>(j.type());
51 case BasicJsonType::value_t::null:
52 case BasicJsonType::value_t::discarded:
54 return combine(type, 0);
57 case BasicJsonType::value_t::object:
59 auto seed = combine(type, j.size());
60 for (
const auto& element : j.items())
62 const auto h = std::hash<string_t> {}(element.key());
63 seed = combine(seed, h);
64 seed = combine(seed,
hash(element.value()));
69 case BasicJsonType::value_t::array:
71 auto seed = combine(type, j.size());
72 for (
const auto& element : j)
74 seed = combine(seed,
hash(element));
79 case BasicJsonType::value_t::string:
81 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
82 return combine(type, h);
85 case BasicJsonType::value_t::boolean:
87 const auto h = std::hash<bool> {}(j.template get<bool>());
88 return combine(type, h);
91 case BasicJsonType::value_t::number_integer:
93 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
94 return combine(type, h);
97 case BasicJsonType::value_t::number_unsigned:
99 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
100 return combine(type, h);
103 case BasicJsonType::value_t::number_float:
105 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
106 return combine(type, h);
109 case BasicJsonType::value_t::binary:
111 auto seed = combine(type, j.get_binary().size());
112 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
113 seed = combine(seed, h);
114 seed = combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
115 for (
const auto byte : j.get_binary())
117 seed = combine(seed, std::hash<std::uint8_t> {}(byte));