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;
221#if SIMDJSON_SUPPORTS_CONCEPTS
229 template <
typename T>
230 simdjson_warn_unused simdjson_inline
error_code get(T &out)
231 noexcept(custom_deserializable<T, object> ? nothrow_custom_deserializable<T, object> :
true) {
232 static_assert(custom_deserializable<T, object>);
233 return deserialize(*
this, out);
241 template <
typename T>
243 noexcept(custom_deserializable<T,
value> ? nothrow_custom_deserializable<T,
value> : true)
245 static_assert(std::is_default_constructible<T>::value,
"The specified type is not default constructible.");
247 SIMDJSON_TRY(get<T>(out));
251#if SIMDJSON_STATIC_REFLECTION
276 template<constevalutil::fixed_string... FieldNames,
typename T>
277 requires(std::is_class_v<T> && (
sizeof...(FieldNames) > 0))
278 simdjson_warn_unused simdjson_inline
error_code extract_into(T& out) &
noexcept;
286 static simdjson_inline
simdjson_result<
object> start(value_iterator &iter) noexcept;
287 static simdjson_inline
simdjson_result<
object> start_root(value_iterator &iter) noexcept;
288 static simdjson_inline
simdjson_result<
object> started(value_iterator &iter) noexcept;
289 static simdjson_inline
object resume(const value_iterator &iter) noexcept;
290 simdjson_inline
object(const value_iterator &iter) noexcept;
292 simdjson_warn_unused simdjson_inline
error_code find_field_raw(const std::string_view key) noexcept;
294 value_iterator iter{};
297 friend class document;
298 friend struct simdjson_result<
object>;
329 #if SIMDJSON_SUPPORTS_CONCEPTS
335 if constexpr (std::is_same_v<T, SIMDJSON_IMPLEMENTATION::ondemand::object>) {
338 return first.get<T>();
341 simdjson_warn_unused simdjson_inline
error_code get(T& out)
noexcept {
343 if constexpr (std::is_same_v<T, SIMDJSON_IMPLEMENTATION::ondemand::object>) {
346 SIMDJSON_TRY( first.get<T>(out) );
351#if SIMDJSON_STATIC_REFLECTION
353 template<constevalutil::fixed_string... FieldNames,
typename T>
354 requires(std::is_class_v<T> && (
sizeof...(FieldNames) > 0))
355 simdjson_warn_unused simdjson_inline
error_code extract_into(T& out)
noexcept {
357 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.