38template <
typename TOptional>
42 using element_type =
typename TOptional::value_type;
53 bool none = lent ? lent->kind() == jsonv::kind::null
68 auto element =
context.extract<element_type>(from);
70 return std::unexpected(element.error());
72 return TOptional(*std::move(element));
76 context.note_value_consumed(from);
Copyright (c) 2015-2026 by Travis Gockel.
Utilities for directly dealing with a JSON AST.
An adapter for the type T.
Provides extra information to routines used for extraction and serialization.
An adapter for optional-like types.
virtual std::expected< TOptional, ast_node_type > create(extraction_context &context, reader &from) const override
Create an instance of T by reading from.
A reader instance reads from some form of JSON source (probably a string) and converts it into a JSON...
ast_node_type current_type() const
Get the type of the current AST node, which is always current().type().
bool next_token() noexcept
Go to the next token.
optional< const value & > current_value() const noexcept
Get the in-memory value this reader is positioned on, if it has one to lend.
Represents a single JSON value, which can be any one of a potential kind, each behaving slightly diff...
Copyright (c) 2014-2020 by Travis Gockel.
#define JSONV_NODISCARD
Warn if the caller discards the result of this function.
Copyright (c) 2019-2020 by Travis Gockel.
Pulls in an implementation of optional.
typename detail::optional_type< T >::type optional
Represents a value that may or may not be present.
Conversion between C++ types and JSON values.