node

Defined in header: <orcus/json_document_tree.hpp>

class node : public orcus::json::const_node

Each node instance represents a JSON value stored in the document tree. This class allows mutable operations.

Public Functions

node() = delete
node(const node &other)
node(node &&rhs)
~node()
node &operator=(const node &other)
node &operator=(const detail::init::node &v)
node operator[](std::string_view key)
node child(size_t index)

Get a child node by index.

Parameters:

index – 0-based index of a child node.

Throws:
  • orcus::json::document_error – if the node is not one of the object or array types.

  • std::out_of_range – if the index is equal to or greater than the number of child nodes that the node has.

Returns:

child node instance.

node child(std::string_view key)

Get a child node by textural key value.

Parameters:

key – textural key value to get a child node by.

Throws:

orcus::json::document_error – if the node is not of the object type, or the node doesn’t have the specified key.

Returns:

child node instance.

node parent()

Get the parent node.

Throws:

orcus::json::document_error – if the node doesn’t have a parent node which implies that the node is a root node.

Returns:

parent node instance.

node back()

Get the last child node.

Throws:

orcus::json::document_error – if the node is not of array type or node has no children.

Returns:

last child node instance.

void push_back(const detail::init::node &v)

Append a new node value to the end of the array.

Throws:

orcus::json::document_error – if the node is not of array type.

Parameters:

v – new node value to append to the end of the array.