@@ -326,7 +326,7 @@ class document::element : protected internal::tape_ref {
326
326
* - INCORRECT_TYPE if a non-integer is used to access an array
327
327
* - INVALID_JSON_POINTER if the JSON pointer is invalid and cannot be parsed
328
328
*/
329
- inline element_result operator [](std::string_view json_pointer) const noexcept ;
329
+ inline element_result operator [](const std::string_view & json_pointer) const noexcept ;
330
330
331
331
/* *
332
332
* Get the value associated with the given JSON pointer.
@@ -360,7 +360,7 @@ class document::element : protected internal::tape_ref {
360
360
* - INCORRECT_TYPE if a non-integer is used to access an array
361
361
* - INVALID_JSON_POINTER if the JSON pointer is invalid and cannot be parsed
362
362
*/
363
- inline element_result at (std::string_view json_pointer) const noexcept ;
363
+ inline element_result at (const std::string_view & json_pointer) const noexcept ;
364
364
365
365
/* *
366
366
* Get the value at the given index.
@@ -382,21 +382,17 @@ class document::element : protected internal::tape_ref {
382
382
* @return The value associated with this field, or:
383
383
* - NO_SUCH_FIELD if the field does not exist in the object
384
384
*/
385
- inline element_result at_key (std::string_view s ) const noexcept ;
385
+ inline element_result at_key (const std::string_view &key ) const noexcept ;
386
386
387
387
/* *
388
- * Get the value associated with the given key.
389
- *
390
- * Note: The key will be matched against **unescaped** JSON:
388
+ * Get the value associated with the given key in a case-insensitive manner.
391
389
*
392
- * document::parser parser;
393
- * parser.parse(R"({ "a\n": 1 })")["a\n"].as_uint64_t().value == 1
394
- * parser.parse(R"({ "a\n": 1 })")["a\\n"].as_uint64_t().error == NO_SUCH_FIELD
390
+ * Note: The key will be matched against **unescaped** JSON.
395
391
*
396
392
* @return The value associated with this field, or:
397
393
* - NO_SUCH_FIELD if the field does not exist in the object
398
394
*/
399
- inline element_result at_key (const char *s ) const noexcept ;
395
+ inline element_result at_key_case_insensitive (const std::string_view &key ) const noexcept ;
400
396
401
397
/* * @private for debugging. Prints out the root element. */
402
398
inline bool dump_raw_tape (std::ostream &out) const noexcept ;
@@ -467,7 +463,7 @@ class document::array : protected internal::tape_ref {
467
463
* - INCORRECT_TYPE if a non-integer is used to access an array
468
464
* - INVALID_JSON_POINTER if the JSON pointer is invalid and cannot be parsed
469
465
*/
470
- inline element_result operator [](std::string_view json_pointer) const noexcept ;
466
+ inline element_result operator [](const std::string_view & json_pointer) const noexcept ;
471
467
472
468
/* *
473
469
* Get the value associated with the given JSON pointer.
@@ -499,7 +495,7 @@ class document::array : protected internal::tape_ref {
499
495
* - INCORRECT_TYPE if a non-integer is used to access an array
500
496
* - INVALID_JSON_POINTER if the JSON pointer is invalid and cannot be parsed
501
497
*/
502
- inline element_result at (std::string_view json_pointer) const noexcept ;
498
+ inline element_result at (const std::string_view & json_pointer) const noexcept ;
503
499
504
500
/* *
505
501
* Get the value at the given index.
@@ -587,7 +583,7 @@ class document::object : protected internal::tape_ref {
587
583
* - INCORRECT_TYPE if a non-integer is used to access an array
588
584
* - INVALID_JSON_POINTER if the JSON pointer is invalid and cannot be parsed
589
585
*/
590
- inline element_result operator [](std::string_view json_pointer) const noexcept ;
586
+ inline element_result operator [](const std::string_view & json_pointer) const noexcept ;
591
587
592
588
/* *
593
589
* Get the value associated with the given JSON pointer.
@@ -619,7 +615,7 @@ class document::object : protected internal::tape_ref {
619
615
* - INCORRECT_TYPE if a non-integer is used to access an array
620
616
* - INVALID_JSON_POINTER if the JSON pointer is invalid and cannot be parsed
621
617
*/
622
- inline element_result at (std::string_view json_pointer) const noexcept ;
618
+ inline element_result at (const std::string_view & json_pointer) const noexcept ;
623
619
624
620
/* *
625
621
* Get the value associated with the given key.
@@ -633,28 +629,8 @@ class document::object : protected internal::tape_ref {
633
629
* @return The value associated with this field, or:
634
630
* - NO_SUCH_FIELD if the field does not exist in the object
635
631
*/
636
- inline element_result at_key (std::string_view s ) const noexcept ;
632
+ inline element_result at_key (const std::string_view &key ) const noexcept ;
637
633
638
- /* *
639
- * Get the value associated with the given key.
640
- *
641
- * Note: The key will be matched against **unescaped** JSON.
642
- *
643
- * @return The value associated with this field, or:
644
- * - NO_SUCH_FIELD if the field does not exist in the object
645
- */
646
- inline element_result at_key (const char *s) const noexcept ;
647
-
648
- /* *
649
- * Get the value associated with the given key, the provided key is
650
- * considered to have length characters.
651
- *
652
- * Note: The key will be matched against **unescaped** JSON.
653
- *
654
- * @return The value associated with this field, or:
655
- * - NO_SUCH_FIELD if the field does not exist in the object
656
- */
657
- inline element_result at_key (const char *s, size_t length) const noexcept ;
658
634
/* *
659
635
* Get the value associated with the given key in a case-insensitive manner.
660
636
*
@@ -663,7 +639,7 @@ class document::object : protected internal::tape_ref {
663
639
* @return The value associated with this field, or:
664
640
* - NO_SUCH_FIELD if the field does not exist in the object
665
641
*/
666
- inline element_result at_key_case_insensitive (const char *s ) const noexcept ;
642
+ inline element_result at_key_case_insensitive (const std::string_view &key ) const noexcept ;
667
643
668
644
private:
669
645
really_inline object (const document *_doc, size_t _json_index) noexcept ;
@@ -682,7 +658,7 @@ class document::key_value_pair {
682
658
document::element value;
683
659
684
660
private:
685
- really_inline key_value_pair (std::string_view _key, document::element _value) noexcept ;
661
+ really_inline key_value_pair (const std::string_view & _key, document::element _value) noexcept ;
686
662
friend class document ::object;
687
663
};
688
664
@@ -704,12 +680,12 @@ class document::element_result : public simdjson_result<document::element> {
704
680
inline array_result as_array () const noexcept ;
705
681
inline object_result as_object () const noexcept ;
706
682
707
- inline element_result operator [](std::string_view json_pointer) const noexcept ;
683
+ inline element_result operator [](const std::string_view & json_pointer) const noexcept ;
708
684
inline element_result operator [](const char *json_pointer) const noexcept ;
709
- inline element_result at (std::string_view json_pointer) const noexcept ;
685
+ inline element_result at (const std::string_view & json_pointer) const noexcept ;
710
686
inline element_result at (size_t index) const noexcept ;
711
- inline element_result at_key (std::string_view key) const noexcept ;
712
- inline element_result at_key (const char * key) const noexcept ;
687
+ inline element_result at_key (const std::string_view & key) const noexcept ;
688
+ inline element_result at_key_case_insensitive (const std::string_view & key) const noexcept ;
713
689
714
690
#if SIMDJSON_EXCEPTIONS
715
691
inline operator bool () const noexcept (false );
@@ -730,9 +706,9 @@ class document::array_result : public simdjson_result<document::array> {
730
706
really_inline array_result (array value) noexcept ;
731
707
really_inline array_result (error_code error) noexcept ;
732
708
733
- inline element_result operator [](std::string_view json_pointer) const noexcept ;
709
+ inline element_result operator [](const std::string_view & json_pointer) const noexcept ;
734
710
inline element_result operator [](const char *json_pointer) const noexcept ;
735
- inline element_result at (std::string_view json_pointer) const noexcept ;
711
+ inline element_result at (const std::string_view & json_pointer) const noexcept ;
736
712
inline element_result at (size_t index) const noexcept ;
737
713
738
714
#if SIMDJSON_EXCEPTIONS
@@ -748,11 +724,11 @@ class document::object_result : public simdjson_result<document::object> {
748
724
really_inline object_result (object value) noexcept ;
749
725
really_inline object_result (error_code error) noexcept ;
750
726
751
- inline element_result operator [](std::string_view json_pointer) const noexcept ;
727
+ inline element_result operator [](const std::string_view & json_pointer) const noexcept ;
752
728
inline element_result operator [](const char *json_pointer) const noexcept ;
753
- inline element_result at (std::string_view json_pointer) const noexcept ;
754
- inline element_result at_key (std::string_view key) const noexcept ;
755
- inline element_result at_key (const char * key) const noexcept ;
729
+ inline element_result at (const std::string_view & json_pointer) const noexcept ;
730
+ inline element_result at_key (const std::string_view & key) const noexcept ;
731
+ inline element_result at_key_case_insensitive (const std::string_view & key) const noexcept ;
756
732
757
733
#if SIMDJSON_EXCEPTIONS
758
734
inline object::iterator begin () const noexcept (false );
@@ -828,7 +804,7 @@ class document::parser {
828
804
* - CAPACITY if the parser does not have enough capacity and len > max_capacity.
829
805
* - other json errors if parsing fails.
830
806
*/
831
- inline element_result load (const std::string& path) noexcept ;
807
+ inline element_result load (const std::string & path) noexcept ;
832
808
833
809
/* *
834
810
* Load a file containing many JSON documents.
@@ -885,7 +861,7 @@ class document::parser {
885
861
* - CAPACITY if the parser does not have enough capacity and batch_size > max_capacity.
886
862
* - other json errors if parsing fails.
887
863
*/
888
- inline document::stream load_many (const std::string& path, size_t batch_size = DEFAULT_BATCH_SIZE) noexcept ;
864
+ inline document::stream load_many (const std::string & path, size_t batch_size = DEFAULT_BATCH_SIZE) noexcept ;
889
865
890
866
/* *
891
867
* Parse a JSON document and return a temporary reference to it.
0 commit comments