xref: /third_party/json/docs/examples/std_hash.cpp (revision c5f01b2f)
1#include <iostream>
2#include <iomanip>
3#include <nlohmann/json.hpp>
4
5using json = nlohmann::json;
6using namespace nlohmann::literals;
7
8int main()
9{
10    std::cout << "hash(null) = " << std::hash<json> {}(json(nullptr)) << '\n'
11              << "hash(false) = " << std::hash<json> {}(json(false)) << '\n'
12              << "hash(0) = " << std::hash<json> {}(json(0)) << '\n'
13              << "hash(0U) = " << std::hash<json> {}(json(0U)) << '\n'
14              << "hash(\"\") = " << std::hash<json> {}(json("")) << '\n'
15              << "hash({}) = " << std::hash<json> {}(json::object()) << '\n'
16              << "hash([]) = " << std::hash<json> {}(json::array()) << '\n'
17              << "hash({\"hello\": \"world\"}) = " << std::hash<json> {}("{\"hello\": \"world\"}"_json)
18              << std::endl;
19}
20