mirror of
https://github.com/nlohmann/json.git
synced 2025-07-06 06:42:33 +03:00
more documentation
This commit is contained in:
18
doc/examples/operator_serialize.cpp
Normal file
18
doc/examples/operator_serialize.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include <json.hpp>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
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";
|
||||
}
|
Reference in New Issue
Block a user