Skip to content

Engine → Core

value.h

JSON values.

Structs

File Description
json::detail::value_access Lets the document and the iterators build views; not for general use.
json::json_converter<bool>
json::json_converter<f32>
json::json_converter<f64>
json::json_converter<i16>
json::json_converter<i32>
json::json_converter<i64>
json::json_converter<i8>
json::json_converter<std::string>
json::json_converter<std::vector<T>> Converts a JSON array element by element. The first failing element stops the conversion and its error is returned with the element index prepended to the message.
json::json_converter<u16>
json::json_converter<u32>
json::json_converter<u64>
json::json_converter<u8>
json::json_converter<uuid>
json::member One key/value pair produced by iterating an object.
std::formatter<conjure::core::json::json_type>

Classes

File Description
json::value A non-owning view of one JSON value inside a document.
json::value::array_iterator Forward iterator over the elements of an array. Dereferencing yields a value view.
json::value::object_iterator Forward iterator over the members of an object. Dereferencing yields a member (key view plus value view).
json::value::object_range Range returned by members(): for (auto [key, item] : object.members()).

Enumerations

json::json_type

enum class json_type : u8 {
    NULL_VALUE,
    BOOL,
    NUMBER,
    STRING,
    ARRAY,
    OBJECT
};

The six JSON value kinds. Invalid values report NULL_VALUE.

Type Aliases

json::value::array_iterator::difference_type

using difference_type = isize;

json::value::array_iterator::iterator_category

using iterator_category = std::forward_iterator_tag;

json::value::array_iterator::pointer

using pointer = void;

json::value::array_iterator::reference

using reference = value;

json::value::array_iterator::value_type

using value_type = value;

json::value::object_iterator::difference_type

using difference_type = isize;

json::value::object_iterator::iterator_category

using iterator_category = std::forward_iterator_tag;

json::value::object_iterator::pointer

using pointer = void;

json::value::object_iterator::reference

using reference = member;

json::value::object_iterator::value_type

using value_type = member;

Concepts

json::json_convertible

template <typename T> concept json_convertible = requires(const value &source) { { json_converter<T>::from_json(source) } -> std::same_as<result<T>>; };

True when json_converter is specialised for T.

Forward Declarations

json::document

class document;

json::json_converter

template <typename T> struct json_converter;

Customisation point for value::to<T>(). Specialise it for a type and provide static result<T> from_json(const value &source). Conversion errors use the generic core codes: NOT_FOUND for an invalid (missing) value, INVALID_ARGUMENT for a type mismatch, OUT_OF_RANGE for a number outside the target range and PARSE_FAILURE for a string that does not parse as the target.

Functions

Public

json::to_string

[[nodiscard]] CONJURE_API std::string_view to_string(json_type type) noexcept;

Returns the lower-case name of a type ("object"), used in error messages.