|
JSON Voorhees
Killer JSON for C++
|
Classes | |
| class | jsonv::parse_index |
| Represents the index of a parsed AST. More... | |
| class | jsonv::kind_error |
Thrown from various value methods when attempting to perform an operation which is not valid for the kind of value. More... | |
| class | jsonv::value |
Represents a single JSON value, which can be any one of a potential kind, each behaving slightly differently. More... | |
| class | jsonv::object_node_handle |
| A node handle used when a value is kind::object to access elements of the object in potentially destructive manner. More... | |
Functions | |
| JSONV_PUBLIC std::string | jsonv::to_string (const value &) |
Get a string representation of the given value. | |
| JSONV_PUBLIC value | jsonv::operator""_json (const char *str, std::size_t len) |
| A user-defined literal for parsing JSON. | |
| JSONV_PUBLIC void | jsonv::swap (value &a, value &b) noexcept |
| Swap the values a and b. | |
| JSONV_PUBLIC value | jsonv::array () |
| Create an empty array value. | |
| JSONV_PUBLIC value | jsonv::array (std::initializer_list< value > source) |
| Create an array value from the given source. | |
| template<typename TForwardIterator > | |
| value | jsonv::array (TForwardIterator first, TForwardIterator last) |
| Create an array with contents defined by range [first, last). | |
| JSONV_PUBLIC value | jsonv::object () |
| Create an empty object. | |
| JSONV_PUBLIC value | jsonv::object (std::initializer_list< std::pair< std::string, value > > source) |
| Create an object with key-value pairs from the given source. | |
| JSONV_PUBLIC value | jsonv::object (std::initializer_list< std::pair< std::wstring, value > > source) |
| template<typename TForwardIterator > | |
| value | jsonv::object (TForwardIterator first, TForwardIterator last) |
| Create an object whose contents are defined by range [first, last). | |
Variables | |
| JSONV_PUBLIC const value | jsonv::null |
An instance with kind::null. | |
| enum class | jsonv::ast_node_type : std::uint8_t { document_end = 0 , document_start = 1 , object_begin = 2 , object_end = 3 , array_begin = 4 , array_end = 5 , string_canonical = 6 , string_escaped = 7 , key_canonical = 8 , key_escaped = 9 , literal_true = 10 , literal_false = 11 , literal_null = 12 , integer = 13 , decimal = 14 , error = 15 } |
| Marker type for an encountered token type. More... | |
| JSONV_PUBLIC std::ostream & | jsonv::operator<< (std::ostream &, const ast_node_type &type) |
| JSONV_PUBLIC std::string | jsonv::to_string (const ast_node_type &type) |
| enum class | jsonv::kind : unsigned char { null , object , array , string , integer , decimal , boolean } |
Describes the kind of data a value holds. More... | |
| JSONV_PUBLIC std::ostream & | jsonv::operator<< (std::ostream &, const kind &) |
Print out the name of the kind. | |
| JSONV_PUBLIC std::string | jsonv::to_string (const kind &) |
Get the name of the kind. | |
JSON value instances.
|
strong |
Marker type for an encountered token type.
document_end The end of a document.document_start The beginning of a document.object_begin The beginning of an kind::object ({).object_end The end of an kind::object (}).array_begin The beginning of an kind::array ([).array_end The end of an kind::array (]).string_canonical A kind::string whose JSON-encoded format matches the canonical UTF-8 representation. There is no need to translate JSON escape sequences to extract a std::string value, so accessing the raw text is safe.string_escaped A kind::string whose JSON-encoded format contains escape sequences, so it must be translated to extract a std::string value.key_canonical The ast_node_type::string_canonical key of an kind::object.key_escaped The ast_node_type::string_escaped key of an kind::object.literal_true The kind::boolean literal true.literal_false The kind::boolean literal false.literal_null The kind::null literal null.integer An kind::integer value. No decimals or exponent symbols were encountered during parsing. Note that integers are not bounds-checked by the AST – values outside of std::int64_t are still integer values.decimal A kind::decimal value.error An AST parsing error.
|
strong |
| value jsonv::array | ( | TForwardIterator | first, |
| TForwardIterator | last | ||
| ) |
| value jsonv::object | ( | TForwardIterator | first, |
| TForwardIterator | last | ||
| ) |
| JSONV_PUBLIC value jsonv::operator""_json | ( | const char * | str, |
| std::size_t | len | ||
| ) |
A user-defined literal for parsing JSON.
Uses the default (non-strict) parse_options.
| JSONV_PUBLIC std::ostream & jsonv::operator<< | ( | std::ostream & | , |
| const ast_node_type & | type | ||
| ) |
+-----------------—+-----—+ | ast_node_type | Output | +-----------------—+-----—+ | document_start | ^ | | document_end | $ | | object_begin | { | | object_end | } | | array_begin | [ | | array_end | ] | | string_canonical | s | | string_escaped | S | | key_canonical | k | | key_escaped | K | | literal_true | t | | literal_false | f | | literal_null | n | | integer | i | | decimal | d | | error | ! | +-----------------—+-----—+
|
extern |
An instance with kind::null.
This is intended to be used for convenience and readability (as opposed to using the default constructor of value.