Template Struct json_sax
Defined in File json.hpp
Struct Documentation
-
template<typename BasicJsonType>
struct json_sax SAX interface.
This class describes the SAX interface used by nlohmann::json::sax_parse. Each function is called in different situations while the input is parsed. The boolean return value informs the parser whether to continue processing the input.
Public Types
-
using number_integer_t = typename BasicJsonType::number_integer_t
type for (signed) integers
-
using number_unsigned_t = typename BasicJsonType::number_unsigned_t
type for unsigned integers
-
using number_float_t = typename BasicJsonType::number_float_t
type for floating-point numbers
-
using string_t = typename BasicJsonType::string_t
type for strings
-
using number_integer_t = typename BasicJsonType::number_integer_t
-
using number_unsigned_t = typename BasicJsonType::number_unsigned_t
-
using number_float_t = typename BasicJsonType::number_float_t
-
using string_t = typename BasicJsonType::string_t
-
using binary_t = typename BasicJsonType::binary_t
Public Functions
-
virtual bool null() = 0
a null value was read
- Returns:
whether parsing should proceed
-
virtual bool boolean(bool val) = 0
a boolean value was read
- Parameters:
val – [in] boolean value
- Returns:
whether parsing should proceed
-
virtual bool number_integer(number_integer_t val) = 0
an integer number was read
- Parameters:
val – [in] integer value
- Returns:
whether parsing should proceed
-
virtual bool number_unsigned(number_unsigned_t val) = 0
an unsigned integer number was read
- Parameters:
val – [in] unsigned integer value
- Returns:
whether parsing should proceed
-
virtual bool number_float(number_float_t val, const string_t &s) = 0
an floating-point number was read
- Parameters:
val – [in] floating-point value
s – [in] raw token value
- Returns:
whether parsing should proceed
-
virtual bool string(string_t &val) = 0
a string was read
Note
It is safe to move the passed string.
- Parameters:
val – [in] string value
- Returns:
whether parsing should proceed
-
virtual bool start_object(std::size_t elements) = 0
the beginning of an object was read
Note
binary formats may report the number of elements
- Parameters:
elements – [in] number of object elements or -1 if unknown
- Returns:
whether parsing should proceed
-
virtual bool key(string_t &val) = 0
an object key was read
Note
It is safe to move the passed string.
- Parameters:
val – [in] object key
- Returns:
whether parsing should proceed
-
virtual bool end_object() = 0
the end of an object was read
- Returns:
whether parsing should proceed
-
virtual bool start_array(std::size_t elements) = 0
the beginning of an array was read
Note
binary formats may report the number of elements
- Parameters:
elements – [in] number of array elements or -1 if unknown
- Returns:
whether parsing should proceed
-
virtual bool end_array() = 0
the end of an array was read
- Returns:
whether parsing should proceed
-
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex) = 0
a parse error occurred
- Parameters:
position – [in] the position in the input where the error occurs
last_token – [in] the last read token
ex – [in] an exception object describing the error
- Returns:
whether parsing should proceed (must return false)
-
virtual ~json_sax() = default
-
virtual bool null() = 0
a null value was read
- Returns:
whether parsing should proceed
-
virtual bool boolean(bool val) = 0
a boolean value was read
- Parameters:
val – [in] boolean value
- Returns:
whether parsing should proceed
-
virtual bool number_integer(number_integer_t val) = 0
an integer number was read
- Parameters:
val – [in] integer value
- Returns:
whether parsing should proceed
-
virtual bool number_unsigned(number_unsigned_t val) = 0
an unsigned integer number was read
- Parameters:
val – [in] unsigned integer value
- Returns:
whether parsing should proceed
-
virtual bool number_float(number_float_t val, const string_t &s) = 0
an floating-point number was read
- Parameters:
val – [in] floating-point value
s – [in] raw token value
- Returns:
whether parsing should proceed
-
virtual bool string(string_t &val) = 0
a string was read
Note
It is safe to move the passed string.
- Parameters:
val – [in] string value
- Returns:
whether parsing should proceed
-
virtual bool binary(binary_t &val) = 0
a binary string was read
Note
It is safe to move the passed binary.
- Parameters:
val – [in] binary value
- Returns:
whether parsing should proceed
-
virtual bool start_object(std::size_t elements) = 0
the beginning of an object was read
Note
binary formats may report the number of elements
- Parameters:
elements – [in] number of object elements or -1 if unknown
- Returns:
whether parsing should proceed
-
virtual bool key(string_t &val) = 0
an object key was read
Note
It is safe to move the passed string.
- Parameters:
val – [in] object key
- Returns:
whether parsing should proceed
-
virtual bool end_object() = 0
the end of an object was read
- Returns:
whether parsing should proceed
-
virtual bool start_array(std::size_t elements) = 0
the beginning of an array was read
Note
binary formats may report the number of elements
- Parameters:
elements – [in] number of array elements or -1 if unknown
- Returns:
whether parsing should proceed
-
virtual bool end_array() = 0
the end of an array was read
- Returns:
whether parsing should proceed
-
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex) = 0
a parse error occurred
- Parameters:
position – [in] the position in the input where the error occurs
last_token – [in] the last read token
ex – [in] an exception object describing the error
- Returns:
whether parsing should proceed (must return false)
-
virtual ~json_sax() = default
-
using number_integer_t = typename BasicJsonType::number_integer_t