• 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 object
9     json j_object = {{"one", 1}, {"two", 2}};
10 
11     // call count()
12     auto count_two = j_object.count("two");
13     auto count_three = j_object.count("three");
14 
15     // print values
16     std::cout << "number of elements with key \"two\": " << count_two << '\n';
17     std::cout << "number of elements with key \"three\": " << count_three << '\n';
18 }
19