|
JSON Voorhees
Killer JSON for C++
|
Configuration for various parsing options. More...
#include <jsonv/parse.hpp>
Classes | |
| struct | k |
Public Types | |
| enum class | encoding { utf8 , utf8_strict } |
| The encoding format for strings. More... | |
| using | size_type = value::size_type |
Public Member Functions | |
| parse_options () | |
| Create an instance with the default options. | |
| encoding | string_encoding () const |
The output encoding for multi-byte characters in strings. The default value is encoding::utf8. | |
| parse_options & | string_encoding (encoding) |
The output encoding for multi-byte characters in strings. The default value is encoding::utf8. | |
| std::optional< size_type > | max_structure_depth () const |
| The maximum allowed nesting depth of any structure in the JSON document. | |
| parse_options & | max_structure_depth (std::optional< size_type > depth) |
| The maximum allowed nesting depth of any structure in the JSON document. | |
| bool | require_document () const |
If set to true, the result of a parse is required to have kind of kind::object or kind::array. | |
| parse_options & | require_document (bool) |
If set to true, the result of a parse is required to have kind of kind::object or kind::array. | |
| bool | comments () const |
Are JSON comments allowed? While there is no official syntax for JSON comments, this uses the de-facto standard of ECMAScript-style block comments: /* comment *‍/. | |
| parse_options & | comments (bool) |
Are JSON comments allowed? While there is no official syntax for JSON comments, this uses the de-facto standard of ECMAScript-style block comments: /* comment *‍/. | |
Static Public Member Functions | |
| static parse_options | create_default () |
| Create a parser with the default options – this is the same result as the default constructor, but might be helpful if you like to be more explicit. | |
| static parse_options | create_strict () |
| Create a strict parser. | |
Configuration for various parsing options.
All parse functions should take in a parse_options as a parameter and should respect your settings.
|
strong |
The encoding format for strings.
| Enumerator | |
|---|---|
| utf8 | Default UTF-8 encoding scheme. Strings must be well-formed UTF-8 as Unicode defines it, which is the same as RFC 3629: every sequence is at most 4 bytes long and is the shortest encoding of its codepoint, and no codepoint is a UTF-16 surrogate (U+D800 through U+DFFF) or above U+10FFFF. A string which breaks any of these is a |
| utf8_strict | Like Where |
|
inline |
Are JSON comments allowed? While there is no official syntax for JSON comments, this uses the de-facto standard of ECMAScript-style block comments: /* comment *‍/.
If this is enabled, comments are treated exactly like whitespace. This is off by default, since RFC 8259 has no comments and a conforming parser rejects them; turn it on for configuration files and other input written in that dialect.
| parse_options & jsonv::parse_options::comments | ( | bool | ) |
Are JSON comments allowed? While there is no official syntax for JSON comments, this uses the de-facto standard of ECMAScript-style block comments: /* comment *‍/.
If this is enabled, comments are treated exactly like whitespace. This is off by default, since RFC 8259 has no comments and a conforming parser rejects them; turn it on for configuration files and other input written in that dialect.
|
static |
Create a strict parser.
In general, these options are meant to fail on anything that is not a 100% valid JSON document. More specifically:
|
inline |
The maximum allowed nesting depth of any structure in the JSON document.
RFC 8259 lets each implementation choose its own nesting limit, so a document that is valid JSON can still be rejected by a low value. By default, the value is nullopt, which means implementations should limit structure depth to k::max_structure_depth. Setting depth to a value above k::max_structure_depth will cause std::invalid_argument to be thrown from parse functions.
| parse_options & jsonv::parse_options::max_structure_depth | ( | std::optional< size_type > | depth | ) |
The maximum allowed nesting depth of any structure in the JSON document.
RFC 8259 lets each implementation choose its own nesting limit, so a document that is valid JSON can still be rejected by a low value. By default, the value is nullopt, which means implementations should limit structure depth to k::max_structure_depth. Setting depth to a value above k::max_structure_depth will cause std::invalid_argument to be thrown from parse functions.
|
inline |
| parse_options & jsonv::parse_options::require_document | ( | bool | ) |
If set to true, the result of a parse is required to have kind of kind::object or kind::array.
By default, this is turned off, which will allow parse to return values with kind::string or kind::integer.
|
inline |
The output encoding for multi-byte characters in strings. The default value is encoding::utf8.