|
json2xml master
C++ header-only json to xml converter
|
#include <json2xml.hpp>


Public Member Functions | |
| JsonSaxConsumer (int tabSpaces=4, char attrPrefix='@') | |
| const std::stringstream & | getXmlStream () const |
| std::string | getXmlString () const |
| const std::string & | getError () const |
| bool | null () override |
| bool | boolean (bool val) override |
| bool | number_integer (number_integer_t val) override |
| bool | number_unsigned (number_unsigned_t val) override |
| bool | number_float (number_float_t, const string_t &s) override |
| bool | string (string_t &val) override |
| bool | binary (binary_t &) override |
| bool | start_object (std::size_t) override |
| bool | end_object () override |
| bool | start_array (std::size_t) override |
| bool | end_array () override |
| bool | key (string_t &val) override |
| bool | parse_error (std::size_t, const std::string &, const nlohmann::json::exception &ex) override |
Json SAX consumer building the XML representation of the parsed json document.
The json layout is the one of python xmltodict, restricted to elements and attributes:
The conversion fails (sax_parse() returns false and getError() tells why) on json parse errors and on what is not supported: text content (an element key with a scalar value, or an array of scalars), nested arrays, attributes at top level, with object/array/null values or repeated, invalid XML names, and characters not allowed in XML 1.0. Attribute values are escaped ('&', '<', '>', '"', tab, line feed and carriage return).
Usage:
A consumer can be reused: every parse starts from scratch.
Definition at line 84 of file json2xml.hpp.
|
inline |
Default constructor
| tabSpaces | Indentation spaces for xml representation, 4 by default. Must be >= 1 or 4 will be asigned. |
| attrPrefix | You could set any other value for attribute prefix, '@' by default. |
Definition at line 256 of file json2xml.hpp.
|
inlineoverride |
Definition at line 316 of file json2xml.hpp.
|
inlineoverride |
Definition at line 291 of file json2xml.hpp.
|
inlineoverride |
Definition at line 364 of file json2xml.hpp.
|
inlineoverride |
Definition at line 336 of file json2xml.hpp.
|
inline |
Returns the reason of the last failed conversion (empty on success)
Definition at line 277 of file json2xml.hpp.
|
inline |
Returns the resulting xml stringstream representation (empty on failure)
Definition at line 263 of file json2xml.hpp.
|
inline |
Returns the resulting xml string representation (empty on failure)
Definition at line 270 of file json2xml.hpp.
|
inlineoverride |
Definition at line 370 of file json2xml.hpp.
|
inlineoverride |
Definition at line 282 of file json2xml.hpp.
|
inlineoverride |
Definition at line 306 of file json2xml.hpp.
|
inlineoverride |
Definition at line 296 of file json2xml.hpp.
|
inlineoverride |
Definition at line 301 of file json2xml.hpp.
|
inlineoverride |
Definition at line 385 of file json2xml.hpp.
|
inlineoverride |
Definition at line 352 of file json2xml.hpp.
|
inlineoverride |
Definition at line 322 of file json2xml.hpp.
|
inlineoverride |
Definition at line 311 of file json2xml.hpp.