mirror of
https://github.com/nlohmann/json.git
synced 2024-11-29 01:49:01 +08:00
24 lines
428 B
C++
24 lines
428 B
C++
#include <json.hpp>
|
|
|
|
using json = nlohmann::json;
|
|
|
|
int main()
|
|
{
|
|
// create JSON values
|
|
json object = {{"one", 1}, {"two", 2}};
|
|
json null;
|
|
|
|
// print values
|
|
std::cout << object << '\n';
|
|
std::cout << null << '\n';
|
|
|
|
// add values
|
|
object.emplace("three", 3);
|
|
null.emplace("A", "a");
|
|
null.emplace("B", "b");
|
|
|
|
// print values
|
|
std::cout << object << '\n';
|
|
std::cout << null << '\n';
|
|
}
|