mirror of
https://github.com/nlohmann/json.git
synced 2025-07-16 18:41:53 +03:00
Add operator<<(json_pointer) (#3601)
* Add operator<< for json_pointer * Deprecate json_pointer::operator string_t() * Update documentation * Move operator<<(basic_json) example * Add example * Add mkdocs-redirects * Move operator<< and operator>> doc pages out of basic_json/ * Rename JSON pointer operator_string to operator_string_t * Add unit test
This commit is contained in:
committed by
GitHub
parent
7777300442
commit
e3095f636f
21
docs/examples/operator_ltlt__basic_json.cpp
Normal file
21
docs/examples/operator_ltlt__basic_json.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
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";
|
||||
std::cout << std::setw(1) << std::setfill('\t') << j_object << "\n\n";
|
||||
}
|
Reference in New Issue
Block a user