document_tree

Defined in header: <orcus/json_document_tree.hpp>

class document_tree

This class stores a parsed JSON document tree structure.

Note

Instance of this class is movable but not copyable.

Public Functions

document_tree()
document_tree(const document_tree&) = delete
document_tree(document_tree &&other)
document_tree(document_resource &res)
document_tree(std::initializer_list<detail::init::node> vs)
document_tree(array vs)
document_tree(object obj)
~document_tree()
document_tree &operator=(std::initializer_list<detail::init::node> vs)
document_tree &operator=(array vs)
document_tree &operator=(object obj)
void load(std::string_view stream, const json_config &config)

Load raw string stream containing a JSON structure to populate the document tree.

Parameters:
  • stream – stream containing a JSON structure.

  • config – configuration object.

json::const_node get_document_root() const

Get the root node of the document.

Returns:

root node of the document.

json::node get_document_root()

Get the root node of the document.

Returns:

root node of the document.

std::string dump(std::size_t indent) const

Dump the JSON document tree to string.

Parameters:

indent – Number of whitespace characters to use for one indent level. Note that specifying the indent value of 0 will generate output without line breaks.

Returns:

a string representation of the JSON document tree.

std::string dump_xml() const

Dump the JSON document tree to an XML structure.

Returns:

a string containing an XML structure representing the JSON content.

std::string dump_yaml() const

Dump the JSON document tree as YAML output.

Returns:

string containing a YAML output representing the JSON document tree structure.

void swap(document_tree &other)

Swap the content of the document with another document instance.

Parameters:

other – document instance to swap the content with.