38template <
typename TOptional>
42 using element_type =
typename TOptional::value_type;
46 virtual std::expected<TOptional, ast_node_type>
54 bool none = lent ? lent->kind() == jsonv::kind::null
69 auto element =
context.deserialize<element_type>(from);
71 return std::unexpected(element.error());
73 return TOptional(*std::move(element));
77 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 deserialization and serialization.
Provides extra information to routines used for deserialization, collects the problems they encounter...
An adapter for optional-like types.
virtual void serialize(const serialization_context &context, const TOptional &from, writer &to) const override
Write from into to.
virtual std::expected< TOptional, ast_node_type > create(deserialization_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.
Provides extra information to routines used for serialization: the formats to find other serializers ...
A writer instance writes a JSON ast_node sequence to some form of sink: an encoder,...
writer & null()
Write a scalar value.
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.