simdjson 4.2.3
Ridiculously Fast JSON
Loading...
Searching...
No Matches
value-inl.h
1#ifndef SIMDJSON_GENERIC_ONDEMAND_VALUE_INL_H
2
3#ifndef SIMDJSON_CONDITIONAL_INCLUDE
4#define SIMDJSON_GENERIC_ONDEMAND_VALUE_INL_H
5#include "simdjson/generic/ondemand/base.h"
6#include "simdjson/generic/ondemand/array.h"
7#include "simdjson/generic/ondemand/array_iterator.h"
8#include "simdjson/generic/ondemand/json_iterator.h"
9#include "simdjson/generic/ondemand/json_type.h"
10#include "simdjson/generic/ondemand/object.h"
11#include "simdjson/generic/ondemand/raw_json_string.h"
12#include "simdjson/generic/ondemand/value.h"
13#endif // SIMDJSON_CONDITIONAL_INCLUDE
14
15namespace simdjson {
16namespace SIMDJSON_IMPLEMENTATION {
17namespace ondemand {
18
19simdjson_inline value::value(const value_iterator &_iter) noexcept
20 : iter{_iter}
21{
22}
23simdjson_inline value value::start(const value_iterator &iter) noexcept {
24 return iter;
25}
26simdjson_inline value value::resume(const value_iterator &iter) noexcept {
27 return iter;
28}
29
30simdjson_inline simdjson_result<array> value::get_array() noexcept {
31 return array::start(iter);
32}
33simdjson_inline simdjson_result<object> value::get_object() noexcept {
34 return object::start(iter);
35}
37 if (iter.at_start()) {
38 return get_object();
39 } else {
40 return object::resume(iter);
41 }
42}
43
45 return iter.get_raw_json_string();
46}
47simdjson_inline simdjson_result<std::string_view> value::get_string(bool allow_replacement) noexcept {
48 return iter.get_string(allow_replacement);
49}
50template <typename string_type>
51simdjson_warn_unused simdjson_inline error_code value::get_string(string_type& receiver, bool allow_replacement) noexcept {
52 return iter.get_string(receiver, allow_replacement);
53}
55 return iter.get_wobbly_string();
56}
57simdjson_inline simdjson_result<double> value::get_double() noexcept {
58 return iter.get_double();
59}
61 return iter.get_double_in_string();
62}
63simdjson_inline simdjson_result<uint64_t> value::get_uint64() noexcept {
64 return iter.get_uint64();
65}
67 return iter.get_uint64_in_string();
68}
69simdjson_inline simdjson_result<int64_t> value::get_int64() noexcept {
70 return iter.get_int64();
71}
73 return iter.get_int64_in_string();
74}
75simdjson_inline simdjson_result<bool> value::get_bool() noexcept {
76 return iter.get_bool();
77}
78simdjson_inline simdjson_result<bool> value::is_null() noexcept {
79 return iter.is_null();
80}
81
82template<> simdjson_inline simdjson_result<array> value::get() noexcept { return get_array(); }
83template<> simdjson_inline simdjson_result<object> value::get() noexcept { return get_object(); }
84template<> simdjson_inline simdjson_result<raw_json_string> value::get() noexcept { return get_raw_json_string(); }
85template<> simdjson_inline simdjson_result<std::string_view> value::get() noexcept { return get_string(false); }
86template<> simdjson_inline simdjson_result<number> value::get() noexcept { return get_number(); }
87template<> simdjson_inline simdjson_result<double> value::get() noexcept { return get_double(); }
88template<> simdjson_inline simdjson_result<uint64_t> value::get() noexcept { return get_uint64(); }
89template<> simdjson_inline simdjson_result<int64_t> value::get() noexcept { return get_int64(); }
90template<> simdjson_inline simdjson_result<bool> value::get() noexcept { return get_bool(); }
91
92
93template<> simdjson_warn_unused simdjson_inline error_code value::get(array& out) noexcept { return get_array().get(out); }
94template<> simdjson_warn_unused simdjson_inline error_code value::get(object& out) noexcept { return get_object().get(out); }
95template<> simdjson_warn_unused simdjson_inline error_code value::get(raw_json_string& out) noexcept { return get_raw_json_string().get(out); }
96template<> simdjson_warn_unused simdjson_inline error_code value::get(std::string_view& out) noexcept { return get_string(false).get(out); }
97template<> simdjson_warn_unused simdjson_inline error_code value::get(number& out) noexcept { return get_number().get(out); }
98template<> simdjson_warn_unused simdjson_inline error_code value::get(double& out) noexcept { return get_double().get(out); }
99template<> simdjson_warn_unused simdjson_inline error_code value::get(uint64_t& out) noexcept { return get_uint64().get(out); }
100template<> simdjson_warn_unused simdjson_inline error_code value::get(int64_t& out) noexcept { return get_int64().get(out); }
101template<> simdjson_warn_unused simdjson_inline error_code value::get(bool& out) noexcept { return get_bool().get(out); }
102
103#if SIMDJSON_EXCEPTIONS
104template <class T>
105simdjson_inline value::operator T() noexcept(false) {
106 return get<T>();
107}
108simdjson_inline value::operator array() noexcept(false) {
109 return get_array();
110}
111simdjson_inline value::operator object() noexcept(false) {
112 return get_object();
113}
114simdjson_inline value::operator uint64_t() noexcept(false) {
115 return get_uint64();
116}
117simdjson_inline value::operator int64_t() noexcept(false) {
118 return get_int64();
119}
120simdjson_inline value::operator double() noexcept(false) {
121 return get_double();
122}
123simdjson_inline value::operator std::string_view() noexcept(false) {
124 return get_string(false);
125}
126simdjson_inline value::operator raw_json_string() noexcept(false) {
127 return get_raw_json_string();
128}
129simdjson_inline value::operator bool() noexcept(false) {
130 return get_bool();
131}
132#endif
133
134simdjson_inline simdjson_result<array_iterator> value::begin() & noexcept {
135 return get_array().begin();
136}
137simdjson_inline simdjson_result<array_iterator> value::end() & noexcept {
138 return {};
139}
140simdjson_inline simdjson_result<size_t> value::count_elements() & noexcept {
142 auto a = get_array();
143 answer = a.count_elements();
144 // count_elements leaves you pointing inside the array, at the first element.
145 // We need to move back so that the user can create a new array (which requires that
146 // we point at '[').
147 iter.move_at_start();
148 return answer;
149}
150simdjson_inline simdjson_result<size_t> value::count_fields() & noexcept {
152 auto a = get_object();
153 answer = a.count_fields();
154 iter.move_at_start();
155 return answer;
156}
157simdjson_inline simdjson_result<value> value::at(size_t index) noexcept {
158 auto a = get_array();
159 return a.at(index);
160}
161
162simdjson_inline simdjson_result<value> value::find_field(std::string_view key) noexcept {
163 return start_or_resume_object().find_field(key);
164}
165simdjson_inline simdjson_result<value> value::find_field(const char *key) noexcept {
166 return start_or_resume_object().find_field(key);
167}
168
169simdjson_inline simdjson_result<value> value::find_field_unordered(std::string_view key) noexcept {
170 return start_or_resume_object().find_field_unordered(key);
171}
172simdjson_inline simdjson_result<value> value::find_field_unordered(const char *key) noexcept {
173 return start_or_resume_object().find_field_unordered(key);
174}
175
176simdjson_inline simdjson_result<value> value::operator[](std::string_view key) noexcept {
177 return start_or_resume_object()[key];
178}
179simdjson_inline simdjson_result<value> value::operator[](const char *key) noexcept {
180 return start_or_resume_object()[key];
181}
182
183simdjson_inline simdjson_result<json_type> value::type() noexcept {
184 return iter.type();
185}
186
187simdjson_inline simdjson_result<bool> value::is_scalar() noexcept {
188 json_type this_type;
189 auto error = type().get(this_type);
190 if(error) { return error; }
191 return ! ((this_type == json_type::array) || (this_type == json_type::object));
192}
193
194simdjson_inline simdjson_result<bool> value::is_string() noexcept {
195 json_type this_type;
196 auto error = type().get(this_type);
197 if(error) { return error; }
198 return (this_type == json_type::string);
199}
200
201
202simdjson_inline bool value::is_negative() noexcept {
203 return iter.is_negative();
204}
205
206simdjson_inline simdjson_result<bool> value::is_integer() noexcept {
207 return iter.is_integer();
208}
209simdjson_warn_unused simdjson_inline simdjson_result<number_type> value::get_number_type() noexcept {
210 return iter.get_number_type();
211}
212simdjson_warn_unused simdjson_inline simdjson_result<number> value::get_number() noexcept {
213 return iter.get_number();
214}
215
216simdjson_inline std::string_view value::raw_json_token() noexcept {
217 return std::string_view(reinterpret_cast<const char*>(iter.peek_start()), iter.peek_start_length());
218}
219
221 json_type t;
222 SIMDJSON_TRY(type().get(t));
223 switch (t)
224 {
225 case json_type::array: {
226 ondemand::array array;
227 SIMDJSON_TRY(get_array().get(array));
228 return array.raw_json();
229 }
230 case json_type::object: {
231 ondemand::object object;
232 SIMDJSON_TRY(get_object().get(object));
233 return object.raw_json();
234 }
235 default:
236 return raw_json_token();
237 }
238}
239
241 return iter.json_iter().current_location();
242}
243
244simdjson_inline int32_t value::current_depth() const noexcept{
245 return iter.json_iter().depth();
246}
247
248inline bool is_pointer_well_formed(std::string_view json_pointer) noexcept {
249 if (simdjson_unlikely(json_pointer.empty())) { // can't be
250 return false;
251 }
252 if (simdjson_unlikely(json_pointer[0] != '/')) {
253 return false;
254 }
255 size_t escape = json_pointer.find('~');
256 if (escape == std::string_view::npos) {
257 return true;
258 }
259 if (escape == json_pointer.size() - 1) {
260 return false;
261 }
262 if (json_pointer[escape + 1] != '0' && json_pointer[escape + 1] != '1') {
263 return false;
264 }
265 return true;
266}
267
268simdjson_inline simdjson_result<value> value::at_pointer(std::string_view json_pointer) noexcept {
269 json_type t;
270 SIMDJSON_TRY(type().get(t));
271 switch (t)
272 {
273 case json_type::array:
274 return (*this).get_array().at_pointer(json_pointer);
276 return (*this).get_object().at_pointer(json_pointer);
277 default:
278 // a non-empty string can be invalid, or accessing a primitive (issue 2154)
279 if (is_pointer_well_formed(json_pointer)) {
280 return NO_SUCH_FIELD;
281 }
283 }
284}
285
286simdjson_inline simdjson_result<value> value::at_path(std::string_view json_path) noexcept {
287 json_type t;
288 SIMDJSON_TRY(type().get(t));
289 switch (t) {
290 case json_type::array:
291 return (*this).get_array().at_path(json_path);
293 return (*this).get_object().at_path(json_path);
294 default:
296 }
297}
298
299inline simdjson_result<std::vector<value>> value::at_path_with_wildcard(std::string_view json_path) noexcept {
300 json_type t;
301 SIMDJSON_TRY(type().get(t));
302 switch (t) {
303 case json_type::array:
304 return (*this).get_array().at_path_with_wildcard(json_path);
306 return (*this).get_object().at_path_with_wildcard(json_path);
307 default:
309 }
310}
311
312} // namespace ondemand
313} // namespace SIMDJSON_IMPLEMENTATION
314} // namespace simdjson
315
316namespace simdjson {
317
318simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::simdjson_result(
319 SIMDJSON_IMPLEMENTATION::ondemand::value &&value
320) noexcept :
321 implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::value>(
322 std::forward<SIMDJSON_IMPLEMENTATION::ondemand::value>(value)
323 )
324{
325}
326simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::simdjson_result(
327 error_code error
328) noexcept :
329 implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::value>(error)
330{
331}
332simdjson_inline simdjson_result<size_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::count_elements() & noexcept {
333 if (error()) { return error(); }
334 return first.count_elements();
335}
336simdjson_inline simdjson_result<size_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::count_fields() & noexcept {
337 if (error()) { return error(); }
338 return first.count_fields();
339}
340simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::at(size_t index) noexcept {
341 if (error()) { return error(); }
342 return first.at(index);
343}
344simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::begin() & noexcept {
345 if (error()) { return error(); }
346 return first.begin();
347}
348simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::end() & noexcept {
349 if (error()) { return error(); }
350 return {};
351}
352
354 if (error()) { return error(); }
355 return first.find_field(key);
356}
358 if (error()) { return error(); }
359 return first.find_field(key);
360}
361
363 if (error()) { return error(); }
364 return first.find_field_unordered(key);
365}
367 if (error()) { return error(); }
368 return first.find_field_unordered(key);
369}
370
371simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator[](std::string_view key) noexcept {
372 if (error()) { return error(); }
373 return first[key];
374}
375simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator[](const char *key) noexcept {
376 if (error()) { return error(); }
377 return first[key];
378}
379
380simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_array() noexcept {
381 if (error()) { return error(); }
382 return first.get_array();
383}
384simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_object() noexcept {
385 if (error()) { return error(); }
386 return first.get_object();
387}
388simdjson_inline simdjson_result<uint64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_uint64() noexcept {
389 if (error()) { return error(); }
390 return first.get_uint64();
391}
392simdjson_inline simdjson_result<uint64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_uint64_in_string() noexcept {
393 if (error()) { return error(); }
394 return first.get_uint64_in_string();
395}
396simdjson_inline simdjson_result<int64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_int64() noexcept {
397 if (error()) { return error(); }
398 return first.get_int64();
399}
400simdjson_inline simdjson_result<int64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_int64_in_string() noexcept {
401 if (error()) { return error(); }
402 return first.get_int64_in_string();
403}
404simdjson_inline simdjson_result<double> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_double() noexcept {
405 if (error()) { return error(); }
406 return first.get_double();
407}
408simdjson_inline simdjson_result<double> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_double_in_string() noexcept {
409 if (error()) { return error(); }
410 return first.get_double_in_string();
411}
412simdjson_inline simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_string(bool allow_replacement) noexcept {
413 if (error()) { return error(); }
414 return first.get_string(allow_replacement);
415}
416template <typename string_type>
417simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_string(string_type& receiver, bool allow_replacement) noexcept {
418 if (error()) { return error(); }
419 return first.get_string(receiver, allow_replacement);
420}
421simdjson_inline simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_wobbly_string() noexcept {
422 if (error()) { return error(); }
423 return first.get_wobbly_string();
424}
425simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_raw_json_string() noexcept {
426 if (error()) { return error(); }
427 return first.get_raw_json_string();
428}
429simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_bool() noexcept {
430 if (error()) { return error(); }
431 return first.get_bool();
432}
433simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::is_null() noexcept {
434 if (error()) { return error(); }
435 return first.is_null();
436}
437
438template<> simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get<SIMDJSON_IMPLEMENTATION::ondemand::value>(SIMDJSON_IMPLEMENTATION::ondemand::value &out) noexcept {
439 if (error()) { return error(); }
440 out = first;
441 return SUCCESS;
442}
443
444template<typename T> simdjson_inline simdjson_result<T> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get() noexcept {
445 if (error()) { return error(); }
446 return first.get<T>();
447}
448template<typename T> simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get(T &out) noexcept {
449 if (error()) { return error(); }
450 return first.get<T>(out);
451}
452
453template<> simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get<SIMDJSON_IMPLEMENTATION::ondemand::value>() noexcept {
454 if (error()) { return error(); }
455 return std::move(first);
456}
457
459 if (error()) { return error(); }
460 return first.type();
461}
463 if (error()) { return error(); }
464 return first.is_scalar();
465}
466simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::is_string() noexcept {
467 if (error()) { return error(); }
468 return first.is_string();
469}
470simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::is_negative() noexcept {
471 if (error()) { return error(); }
472 return first.is_negative();
473}
474simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::is_integer() noexcept {
475 if (error()) { return error(); }
476 return first.is_integer();
477}
478simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::number_type> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_number_type() noexcept {
479 if (error()) { return error(); }
480 return first.get_number_type();
481}
482simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::number> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::get_number() noexcept {
483 if (error()) { return error(); }
484 return first.get_number();
485}
486#if SIMDJSON_EXCEPTIONS
487template <class T>
488simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator T() noexcept(false) {
489 if (error()) { throw simdjson_error(error()); }
490 return first.get<T>();
491}
492simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator SIMDJSON_IMPLEMENTATION::ondemand::array() noexcept(false) {
493 if (error()) { throw simdjson_error(error()); }
494 return first;
495}
496simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator SIMDJSON_IMPLEMENTATION::ondemand::object() noexcept(false) {
497 if (error()) { throw simdjson_error(error()); }
498 return first;
499}
500simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator uint64_t() noexcept(false) {
501 if (error()) { throw simdjson_error(error()); }
502 return first;
503}
504simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator int64_t() noexcept(false) {
505 if (error()) { throw simdjson_error(error()); }
506 return first;
507}
508simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator double() noexcept(false) {
509 if (error()) { throw simdjson_error(error()); }
510 return first;
511}
512simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator std::string_view() noexcept(false) {
513 if (error()) { throw simdjson_error(error()); }
514 return first;
515}
516simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string() noexcept(false) {
517 if (error()) { throw simdjson_error(error()); }
518 return first;
519}
520simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::operator bool() noexcept(false) {
521 if (error()) { throw simdjson_error(error()); }
522 return first;
523}
524#endif
525
527 if (error()) { return error(); }
528 return first.raw_json_token();
529}
530
532 if (error()) { return error(); }
533 return first.raw_json();
534}
535
537 if (error()) { return error(); }
538 return first.current_location();
539}
540
542 if (error()) { return error(); }
543 return first.current_depth();
544}
545
547 std::string_view json_pointer) noexcept {
548 if (error()) {
549 return error();
550 }
551 return first.at_pointer(json_pointer);
552}
553
554simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::at_path(
555 std::string_view json_path) noexcept {
556 if (error()) {
557 return error();
558 }
559 return first.at_path(json_path);
560}
561
562inline simdjson_result<std::vector<SIMDJSON_IMPLEMENTATION::ondemand::value>> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>::at_path_with_wildcard(
563 std::string_view json_path) noexcept {
564 if (error()) {
565 return error();
566 }
567 return first.at_path_with_wildcard(json_path);
568}
569
570} // namespace simdjson
571
572#endif // SIMDJSON_GENERIC_ONDEMAND_VALUE_INL_H
static simdjson_inline simdjson_result< array > start(value_iterator &iter) noexcept
Begin array iteration.
Definition array-inl.h:61
simdjson_inline simdjson_result< std::string_view > raw_json() noexcept
Consumes the array and returns a string_view instance corresponding to the array as represented in JS...
Definition array-inl.h:94
A forward-only JSON object field iterator.
Definition object.h:21
A string escaped per JSON rules, terminated with quote (").
An ephemeral JSON value returned during iteration.
Definition value.h:22
static simdjson_inline value start(const value_iterator &iter) noexcept
Start a value at the current position.
Definition value-inl.h:23
simdjson_inline simdjson_result< bool > is_null() noexcept
Checks if this JSON value is null.
Definition value-inl.h:78
simdjson_inline simdjson_result< const char * > current_location() noexcept
Returns the current location in the document if in bounds.
Definition value-inl.h:240
simdjson_inline simdjson_result< value > find_field(std::string_view key) noexcept
Look up a field by name on an object (order-sensitive).
Definition value-inl.h:162
simdjson_inline simdjson_result< T > get() noexcept
Get this value as the given type.
Definition value.h:44
simdjson_inline bool is_negative() noexcept
Checks whether the value is a negative number.
Definition value-inl.h:202
simdjson_inline simdjson_result< number_type > get_number_type() noexcept
Determine the number type (integer or floating-point number) as quickly as possible.
Definition value-inl.h:209
simdjson_inline simdjson_result< array > get_array() noexcept
Cast this JSON value to an array.
Definition value-inl.h:30
simdjson_inline 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.
Definition value-inl.h:299
simdjson_inline std::string_view raw_json_token() noexcept
Get the raw JSON for this token.
Definition value-inl.h:216
simdjson_inline simdjson_result< object > get_object() noexcept
Cast this JSON value to an object.
Definition value-inl.h:33
simdjson_inline simdjson_result< size_t > count_elements() &noexcept
This method scans the array and counts the number of elements.
Definition value-inl.h:140
simdjson_inline simdjson_result< int64_t > get_int64_in_string() noexcept
Cast this JSON value (inside string) to a signed integer.
Definition value-inl.h:72
simdjson_inline simdjson_result< size_t > count_fields() &noexcept
This method scans the object and counts the number of key-value pairs.
Definition value-inl.h:150
simdjson_inline simdjson_result< bool > is_integer() noexcept
Checks whether the value is an integer number.
Definition value-inl.h:206
simdjson_inline simdjson_result< array_iterator > end() &noexcept
Sentinel representing the end of the array.
Definition value-inl.h:137
simdjson_inline simdjson_result< value > at_path(std::string_view at_path) noexcept
Get the value associated with the given JSONPath expression.
Definition value-inl.h:286
simdjson_inline simdjson_result< object > start_or_resume_object() noexcept
Get the object, starting or resuming it as necessary.
Definition value-inl.h:36
simdjson_inline simdjson_result< array_iterator > begin() &noexcept
Begin array iteration.
Definition value-inl.h:134
simdjson_inline simdjson_result< uint64_t > get_uint64_in_string() noexcept
Cast this JSON value (inside string) to a unsigned integer.
Definition value-inl.h:66
simdjson_inline int32_t current_depth() const noexcept
Returns the current depth in the document if in bounds.
Definition value-inl.h:244
simdjson_inline simdjson_result< bool > is_scalar() noexcept
Checks whether the value is a scalar (string, number, null, Boolean).
Definition value-inl.h:187
simdjson_inline simdjson_result< std::string_view > raw_json() noexcept
Get a string_view pointing at this value in the JSON document.
Definition value-inl.h:220
static simdjson_inline value resume(const value_iterator &iter) noexcept
Resume a value.
Definition value-inl.h:26
simdjson_inline simdjson_result< double > get_double() noexcept
Cast this JSON value to a double.
Definition value-inl.h:57
simdjson_inline simdjson_result< std::string_view > get_string(bool allow_replacement=false) noexcept
Cast this JSON value to a string.
Definition value-inl.h:47
simdjson_inline simdjson_result< bool > get_bool() noexcept
Cast this JSON value to a bool.
Definition value-inl.h:75
simdjson_warn_unused simdjson_inline simdjson_result< number > get_number() noexcept
Attempt to parse an ondemand::number.
Definition value-inl.h:212
simdjson_inline simdjson_result< value > at_pointer(std::string_view json_pointer) noexcept
Get the value associated with the given JSON pointer.
Definition value-inl.h:268
simdjson_inline simdjson_result< std::string_view > get_wobbly_string() noexcept
Cast this JSON value to a "wobbly" string.
Definition value-inl.h:54
simdjson_inline simdjson_result< int64_t > get_int64() noexcept
Cast this JSON value to a signed integer.
Definition value-inl.h:69
simdjson_inline value() noexcept=default
Create a new invalid value.
simdjson_inline simdjson_result< json_type > type() noexcept
Get the type of this JSON value.
Definition value-inl.h:183
simdjson_inline simdjson_result< double > get_double_in_string() noexcept
Cast this JSON value (inside string) to a double.
Definition value-inl.h:60
simdjson_inline simdjson_result< raw_json_string > get_raw_json_string() noexcept
Cast this JSON value to a raw_json_string.
Definition value-inl.h:44
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.
Definition value-inl.h:169
simdjson_inline simdjson_result< value > at(size_t index) noexcept
Get the value at the given index in the array.
Definition value-inl.h:157
simdjson_inline simdjson_result< uint64_t > get_uint64() noexcept
Cast this JSON value to an unsigned integer.
Definition value-inl.h:63
simdjson_inline simdjson_result< bool > is_string() noexcept
Checks whether the value is a string.
Definition value-inl.h:194
@ object
A JSON object ( { "a": 1, "b" 2, ... } )
@ string
A JSON string ( "a" or "hello world\n" ...)
The top level simdjson namespace, containing everything the library provides.
Definition base.h:8
error_code
All possible errors returned by simdjson.
Definition error.h:19
@ NO_SUCH_FIELD
JSON field not found in object.
Definition error.h:40
@ SUCCESS
No error.
Definition error.h:20
@ INVALID_JSON_POINTER
Invalid JSON pointer syntax.
Definition error.h:42
The result of a simdjson operation that could fail.
Definition error.h:280
simdjson_warn_unused simdjson_inline error_code get(T &value) &&noexcept
Move the value to the provided variable.
Definition error-inl.h:163