+ template<typename CHAR = char>
+ json_formatter class final
+
+ A wrapper for printing TOML objects out to a stream as formatted JSON.
+| Template parameters | |
|---|---|
| CHAR | +The underlying character type of the output stream. Must be 1 byte in size. | +
Contents
+-
+
- + Reference + + +
auto some_toml = toml::parse(R"( + [fruit] + apple.color = "red" + apple.taste.sweet = true + + [fruit.apple.texture] + smooth = true +)"sv); +std::cout << toml::json_formatter{ some_toml } << std::endl; + +// output: +// { +// "fruit" : { +// "apple" : { +// "color" : "red", +// "taste" : { +// "sweet" : true +// }, +// "texture" : { +// "smooth" : true +// } +// } +// } +// }+
Constructors, destructors, conversion operators
+-
+
-
+ json_formatter(const toml::
node& source, + format_flags flags = format_flags::quote_dates_and_times) explicit noexcept +
+ - Constructs a JSON formatter and binds it to a TOML object. +
Friends
+-
+
-
+ template<typename T>+ auto operator<<(std::basic_ostream<T>& lhs, + json_
formatter&& rhs) -> std::basic_ostream<CHAR>& +
+ - Prints the bound TOML object out to the stream as JSON (rvalue overload). +
-
+ template<typename T>+ auto operator<<(std::basic_ostream<T>& lhs, + json_
formatter& rhs) -> std::basic_ostream<T>& +
+ - Prints the bound TOML object out to the stream as JSON. +
Function documentation
+
+
+ template<typename CHAR>
+
+ toml:: json_formatter<CHAR>:: json_formatter(const toml:: node& source,
+ format_flags flags = format_flags::quote_dates_and_times) explicit noexcept
+
+ Constructs a JSON formatter and binds it to a TOML object.
+| Parameters | |
|---|---|
| source | +The source TOML object. | +
| flags | +Format option flags. | +