Using boost::json::serializer as shown in the example in docs - quick look saves the json-tree in compact format.
Is there a way to instruct the serializer to output a human readable file (i.e. with newlines and whitespaces)? I searched around, but didn't find any hints.
NB: Even better would be writing the higher levels of the tree readably, and some objects, or arrays (maybe marked ones) in compact format.
The shortened example code could look like this:
#include <iostream>
#include <boost/json.hpp>
#include <boost/json/src.hpp> // use header-only
using namespace boost;
int main(int /*argc*/, char */*argv*/[]) {
json::value jv = {
{ "pi", 3.141 },
{"list", {1, 0, 2}},
};
json::serializer sr;
sr.reset( &jv );
do {
char buf[ 16 ];
std::cout << sr.read( buf );
} while( ! sr.done() );
}
This (correctly) outputs {"pi":3.141E0,"list":[1,0,2]}, but I'd rather have:
{
"pi":3.141E0,
"list":
[
1,
0,
2
]
}
or (the "NB"-version):
{
"pi":3.141E0,
"list":[1,0,2]
}
Is this possible with boost::json without writing it myself?