You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#include "nlohmann/json.hpp"
#include <iostream>
void aaa() {
// create an empty structure (null)
nlohmann::json j;
// add a number that is stored as double (note the implicit conversion of j to an object)
j["pi"] = 3.141;
// add a Boolean that is stored as bool
j["happy"] = true;
// add a string that is stored as std::string
j["name"] = "Niels";
// add another null object by passing nullptr
j["nothing"] = nullptr;
// add an object inside the object
j["answer"]["everything"] = 42;
// add an array that is stored as std::vector (using an initializer list)
j["list"] = { 1, 0, 2 };
// add another object (using an initializer list of pairs)
j["object"] = { {"currency", "USD"}, {"value", 42.99} };
std::string serialized_string = j.dump();
std::cout << serialized_string << "\n";
}
int main() {
for (int i=0; i<100; i++) {
aaa();
}
return 123;
}
Commit: 8f0ca5e
Test code
nlohmann/json.hpp
can be found at hereOutput
The text was updated successfully, but these errors were encountered: