1#ifndef SIMDJSON_GENERIC_ONDEMAND_OBJECT_H
3#ifndef SIMDJSON_CONDITIONAL_INCLUDE
4#define SIMDJSON_GENERIC_ONDEMAND_OBJECT_H
5#include "simdjson/generic/ondemand/base.h"
6#include "simdjson/generic/implementation_simdjson_result_base.h"
7#include "simdjson/generic/ondemand/value_iterator.h"
9#if SIMDJSON_STATIC_REFLECTION && SIMDJSON_SUPPORTS_CONCEPTS
10#include "simdjson/generic/ondemand/json_string_builder.h"
15namespace SIMDJSON_IMPLEMENTATION {
28 simdjson_inline
object() noexcept = default;
218#if SIMDJSON_SUPPORTS_CONCEPTS
226 template <
typename T>
227 simdjson_warn_unused simdjson_inline
error_code get(T &out)
228 noexcept(custom_deserializable<T, object> ? nothrow_custom_deserializable<T, object> :
true) {
229 static_assert(custom_deserializable<T, object>);
230 return deserialize(*
this, out);
238 template <
typename T>
240 noexcept(custom_deserializable<T,
value> ? nothrow_custom_deserializable<T,
value> : true)
242 static_assert(std::is_default_constructible<T>::value,
"The specified type is not default constructible.");
244 SIMDJSON_TRY(get<T>(out));
248#if SIMDJSON_STATIC_REFLECTION
273 template<constevalutil::fixed_string... FieldNames,
typename T>
274 requires(std::is_class_v<T> && (
sizeof...(FieldNames) > 0))
275 simdjson_warn_unused simdjson_inline
error_code extract_into(T& out) &
noexcept;
283 static simdjson_inline
simdjson_result<
object> start(value_iterator &iter) noexcept;
284 static simdjson_inline
simdjson_result<
object> start_root(value_iterator &iter) noexcept;
285 static simdjson_inline
simdjson_result<
object> started(value_iterator &iter) noexcept;
286 static simdjson_inline
object resume(const value_iterator &iter) noexcept;
287 simdjson_inline
object(const value_iterator &iter) noexcept;
289 simdjson_warn_unused simdjson_inline
error_code find_field_raw(const std::string_view key) noexcept;
291 value_iterator iter{};
294 friend class document;
295 friend struct simdjson_result<
object>;
326 #if SIMDJSON_SUPPORTS_CONCEPTS
332 if constexpr (std::is_same_v<T, SIMDJSON_IMPLEMENTATION::ondemand::object>) {
335 return first.get<T>();
338 simdjson_warn_unused simdjson_inline
error_code get(T& out)
noexcept {
340 if constexpr (std::is_same_v<T, SIMDJSON_IMPLEMENTATION::ondemand::object>) {
343 SIMDJSON_TRY( first.get<T>(out) );
348#if SIMDJSON_STATIC_REFLECTION
350 template<constevalutil::fixed_string... FieldNames,
typename T>
351 requires(std::is_class_v<T> && (
sizeof...(FieldNames) > 0))
352 simdjson_warn_unused simdjson_inline
error_code extract_into(T& out)
noexcept {
354 return first.extract_into<FieldNames...>(out);
A forward-only JSON object field iterator.
simdjson_inline object() noexcept=default
Create a new invalid object.
simdjson_inline simdjson_result< value > find_field_unordered(std::string_view key) &noexcept
Look up a field by name on an object, without regard to key order.
simdjson_inline simdjson_result< std::string_view > raw_json() noexcept
Consumes the object and returns a string_view instance corresponding to the object as represented in ...
simdjson_warn_unused simdjson_inline error_code consume() noexcept
Go to the end of the object, no matter where you are right now.
simdjson_inline simdjson_result< value > find_field(std::string_view key) &noexcept
Look up a field by name on an object (order-sensitive).
simdjson_result< std::vector< value > > at_path_with_wildcard(std::string_view json_path) noexcept
Get all values matching the given JSONPath expression with wildcard support.
simdjson_result< bool > is_empty() &noexcept
This method scans the beginning of the object and checks whether the object is empty.
simdjson_result< bool > reset() &noexcept
Reset the iterator so that we are pointing back at the beginning of the object.
simdjson_result< value > at_path(std::string_view json_path) noexcept
Get the value associated with the given JSONPath expression.
simdjson_result< value > at_pointer(std::string_view json_pointer) noexcept
Get the value associated with the given JSON pointer.
simdjson_inline simdjson_result< size_t > count_fields() &noexcept
This method scans the object and counts the number of key-value pairs.
An ephemeral JSON value returned during iteration.
The top level simdjson namespace, containing everything the library provides.
error_code
All possible errors returned by simdjson.
The result of a simdjson operation that could fail.
The result of a simdjson operation that could fail.
simdjson_inline error_code error() const noexcept
The error.
simdjson_warn_unused simdjson_inline error_code get(T &value) &&noexcept
Move the value to the provided variable.