2015-06-21 20:42:32 +00:00
|
|
|
#include <json.hpp>
|
2017-04-14 15:37:28 +00:00
|
|
|
#include <iomanip> // for std::setw
|
2015-06-21 20:42:32 +00:00
|
|
|
|
2016-01-30 19:23:14 +00:00
|
|
|
using json = nlohmann::json;
|
2015-06-21 20:42:32 +00:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
// create JSON values
|
|
|
|
json j_object = {{"one", 1}, {"two", 2}};
|
|
|
|
json j_array = {1, 2, 4, 8, 16};
|
|
|
|
|
|
|
|
// serialize without indentation
|
|
|
|
std::cout << j_object << "\n\n";
|
|
|
|
std::cout << j_array << "\n\n";
|
|
|
|
|
|
|
|
// serialize with indentation
|
|
|
|
std::cout << std::setw(4) << j_object << "\n\n";
|
|
|
|
std::cout << std::setw(2) << j_array << "\n\n";
|
|
|
|
}
|