• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <iostream>
2 #include <nlohmann/json.hpp>
3 
4 using json = nlohmann::json;
5 using std::to_string;
6 
main()7 int main()
8 {
9     // create values
10     json j = {{"one", 1}, {"two", 2}};
11     int i = 42;
12 
13     // use ADL to select best to_string function
14     auto j_str = to_string(j);  // calling nlohmann::to_string
15     auto i_str = to_string(i);  // calling std::to_string
16 
17     // serialize without indentation
18     std::cout << j_str << "\n\n"
19               << i_str << std::endl;
20 }
21