9#if !TOML_IMPLEMENTATION
10#error This is an implementation-only header.
13#if TOML_ENABLE_FORMATTERS
23 void json_formatter::print(
const toml::table& tbl) {
25 print_unformatted(
"{}"sv);
29 print_unformatted(
'{');
33 for (
auto&& [
k,
v] : tbl) {
34 if (first) print_unformatted(
',');
39 print_string(
k.str(),
false);
41 print_unformatted(
":"sv);
43 print_unformatted(
" : "sv);
45 const auto type =
v.type();
48 case node_type::table:
51 case node_type::array:
62 print_unformatted(
'}');
66 void json_formatter::print(
const toml::array& arr) {
68 print_unformatted(
"[]"sv);
72 print_unformatted(
'[');
74 for (
size_t i = 0;
i < arr.size();
i++) {
75 if (
i > 0
u) print_unformatted(
',');
80 const auto type =
v.type();
83 case node_type::table:
86 case node_type::array:
96 print_unformatted(
']');
100 void json_formatter::print() {
101 if (dump_failed_parse_result())
return;
103 switch (
auto source_type = source().type()) {
104 case node_type::table:
105 print(*
reinterpret_cast<const table*
>(&source()));
107 case node_type::array:
108 print(*
reinterpret_cast<const array*
>(&source()));
111 print_value(source(), source_type);
enum TOML_CLOSED_FLAGS_ENUM indent_sub_tables
Apply indentation to tables nested within other tables/arrays.
enum TOML_CLOSED_FLAGS_ENUM indent_array_elements
Apply indentation to array elements when the array is forced to wrap over multiple lines.
#define TOML_EXTERNAL_LINKAGE
#define TOML_NAMESPACE_END
#define TOML_ASSUME(expr)