53 auto& os = target->ostream();
54 print_value( document, os );
59 std::stringstream sstr;
60 print_value( document, sstr );
68 void JsonWriter::print_value(
72 switch(value.
type()) {
98 print_array( value, out, 0 );
102 print_object( value, out, 0 );
111 void JsonWriter::print_array(
112 JsonDocument
const& value,
116 int il = indent_level + 1;
117 std::string in (il * indent_,
' ');
121 bool has_large =
false;
122 for(
auto const& elem : value ) {
123 has_large |= ( elem.is_array() || elem.is_object());
128 for(
auto const& elem : value ) {
135 if (elem.is_array()) {
136 print_array( elem, out, il );
137 }
else if ( elem.is_object() ) {
138 print_object( elem, out, il );
140 print_value( elem, out );
146 out <<
"\n" << std::string(indent_level * indent_,
' ');
153 void JsonWriter::print_object(
154 JsonDocument
const& value,
158 int il = indent_level + 1;
159 std::string in (il * indent_,
' ');
163 for(
auto it = value.begin(); it != value.end(); ++it ) {
167 out <<
"\n" << in <<
"\"" << it.key() <<
"\": ";
168 if ( it.value().is_array() ) {
169 print_array( it.value(), out, il );
170 }
else if( it.value().is_object() ) {
171 print_object( it.value(), out, il );
173 print_value( it.value(), out );
178 out <<
"\n" << std::string(indent_level * indent_,
' ') <<
"}";