• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <iostream>
2 #include <nlohmann/json.hpp>
3 
4 using json = nlohmann::json;
5 
main()6 int main()
7 {
8     // create a JSON value
9     const json j =
10     {
11         {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
12     };
13 
14     // read-only access
15 
16     // output element with JSON pointer "/number"
17     std::cout << j["/number"_json_pointer] << '\n';
18     // output element with JSON pointer "/string"
19     std::cout << j["/string"_json_pointer] << '\n';
20     // output element with JSON pointer "/array"
21     std::cout << j["/array"_json_pointer] << '\n';
22     // output element with JSON pointer "/array/1"
23     std::cout << j["/array/1"_json_pointer] << '\n';
24 }
25