![]() |
simdjson 4.1.0
Ridiculously Fast JSON
|
The top level simdjson namespace, containing everything the library provides. More...
Namespaces | |
| namespace | arm64 |
| Implementation for NEON (ARMv8). | |
| namespace | dom |
| A DOM API on top of the simdjson parser. | |
| namespace | fallback |
| Fallback implementation (runs on any machine). | |
| namespace | haswell |
| Implementation for Haswell (Intel AVX2). | |
| namespace | icelake |
| Implementation for Icelake (Intel AVX512). | |
| namespace | lasx |
| Implementation for LASX. | |
| namespace | lsx |
| Implementation for LSX. | |
| namespace | ppc64 |
| Implementation for ALTIVEC (PPC64). | |
| namespace | westmere |
| Implementation for Westmere (Intel SSE4.2). | |
Typedefs | |
| using | ErrorValues = error_code |
Enumerations | |
| enum | error_code { SUCCESS = 0 , CAPACITY , MEMALLOC , TAPE_ERROR , DEPTH_ERROR , STRING_ERROR , T_ATOM_ERROR , F_ATOM_ERROR , N_ATOM_ERROR , NUMBER_ERROR , BIGINT_ERROR , UTF8_ERROR , UNINITIALIZED , EMPTY , UNESCAPED_CHARS , UNCLOSED_STRING , UNSUPPORTED_ARCHITECTURE , INCORRECT_TYPE , NUMBER_OUT_OF_RANGE , INDEX_OUT_OF_BOUNDS , NO_SUCH_FIELD , IO_ERROR , INVALID_JSON_POINTER , INVALID_URI_FRAGMENT , UNEXPECTED_ERROR , PARSER_IN_USE , OUT_OF_ORDER_ITERATION , INSUFFICIENT_PADDING , INCOMPLETE_ARRAY_OR_OBJECT , SCALAR_DOCUMENT_AS_VALUE , OUT_OF_BOUNDS , TRAILING_CONTENT , OUT_OF_CAPACITY , NUM_ERROR_CODES } |
| All possible errors returned by simdjson. More... | |
| enum class | stage1_mode { regular , streaming_partial , streaming_final } |
| This enum is used with the dom_parser_implementation::stage1 function. More... | |
| enum | { SIMDJSON_VERSION_MAJOR = 4 , SIMDJSON_VERSION_MINOR = 1 , SIMDJSON_VERSION_REVISION = 0 } |
Functions | |
| const implementation * | builtin_implementation () |
| Function which returns a pointer to an implementation matching the "builtin" implementation. | |
| template<class T > | |
| std::string | to_string (T x) |
| Converts JSON to a string. | |
| template<class T > | |
| std::string | to_string (simdjson_result< T > x) |
| template<class T > | |
| std::string | minify (T x) |
| Minifies a JSON element or document, printing the smallest possible valid JSON. | |
| template<class T > | |
| std::string | minify (simdjson_result< T > x) |
| template<class T > | |
| std::string | prettify (T x) |
| Prettifies a JSON element or document, printing the valid JSON with indentation. | |
| template<class T > | |
| std::string | prettify (simdjson_result< T > x) |
| bool | is_fatal (error_code error) noexcept |
| Some errors are fatal and invalidate the document. | |
| const char * | error_message (error_code error) noexcept |
| It is the convention throughout the code that the macro SIMDJSON_DEVELOPMENT_CHECKS determines whether we check for OUT_OF_ORDER_ITERATION. | |
| const std::string | error_message (int error) noexcept |
| std::ostream & | operator<< (std::ostream &out, error_code error) noexcept |
| Write the error message to the output stream. | |
| template<typename T > | |
| std::ostream & | operator<< (std::ostream &out, simdjson_result< T > value) |
| template<class Z > | |
| simdjson_warn_unused simdjson_result< std::string > | to_json (const Z &z, size_t initial_capacity=simdjson::SIMDJSON_IMPLEMENTATION::builder::string_builder::DEFAULT_INITIAL_CAPACITY) |
| template<class Z > | |
| simdjson_warn_unused simdjson_error | to_json (const Z &z, std::string &s, size_t initial_capacity=simdjson::SIMDJSON_IMPLEMENTATION::builder::string_builder::DEFAULT_INITIAL_CAPACITY) |
| std::string_view | trim (const std::string_view str) noexcept |
| simdjson_result< std::string_view > | to_json_string (SIMDJSON_IMPLEMENTATION::ondemand::document &x) noexcept |
| Create a string-view instance out of a document instance. | |
| simdjson_result< std::string_view > | to_json_string (SIMDJSON_IMPLEMENTATION::ondemand::document_reference &x) noexcept |
| simdjson_result< std::string_view > | to_json_string (SIMDJSON_IMPLEMENTATION::ondemand::value &x) noexcept |
| Create a string-view instance out of a value instance. | |
| simdjson_result< std::string_view > | to_json_string (SIMDJSON_IMPLEMENTATION::ondemand::object &x) noexcept |
| Create a string-view instance out of an object instance. | |
| simdjson_result< std::string_view > | to_json_string (SIMDJSON_IMPLEMENTATION::ondemand::array &x) noexcept |
| Create a string-view instance out of an array instance. | |
| simdjson_result< std::string_view > | to_json_string (simdjson_result< SIMDJSON_IMPLEMENTATION::ondemand::document > x) |
| simdjson_result< std::string_view > | to_json_string (simdjson_result< SIMDJSON_IMPLEMENTATION::ondemand::document_reference > x) |
| simdjson_result< std::string_view > | to_json_string (simdjson_result< SIMDJSON_IMPLEMENTATION::ondemand::value > x) |
| simdjson_result< std::string_view > | to_json_string (simdjson_result< SIMDJSON_IMPLEMENTATION::ondemand::object > x) |
| simdjson_result< std::string_view > | to_json_string (simdjson_result< SIMDJSON_IMPLEMENTATION::ondemand::array > x) |
| simdjson_warn_unused bool | validate_utf8 (const char *buf, size_t len) noexcept |
| Validate the UTF-8 string. | |
| simdjson_inline simdjson_warn_unused bool | validate_utf8 (const std::string_view sv) noexcept |
| Validate the UTF-8 string. | |
| simdjson_inline simdjson_warn_unused bool | validate_utf8 (const std::string &s) noexcept |
| Validate the UTF-8 string. | |
| SIMDJSON_DLLIMPORTEXPORT const internal::available_implementation_list & | get_available_implementations () |
| The list of available implementations compiled into simdjson. | |
| SIMDJSON_DLLIMPORTEXPORT internal::atomic_ptr< const implementation > & | get_active_implementation () |
| The active implementation. | |
| bool | is_streaming (stage1_mode mode) |
| Returns true if mode == streaming_partial or mode == streaming_final. | |
| padded_string | get_corpus (const char *path) |
| std::string | json_path_to_pointer_conversion (std::string_view json_path) |
| Converts JSONPath to JSON Pointer. | |
| std::pair< std::string_view, std::string_view > | get_next_key_and_json_path (std::string_view &json_path) |
| simdjson_warn_unused error_code | minify (const char *buf, size_t len, char *dst, size_t &dst_len) noexcept |
| Minify the input string assuming that it represents a JSON string, does not parse or validate. | |
| std::ostream & | operator<< (std::ostream &out, const padded_string &s) |
| Send padded_string instance to an output stream. | |
| std::ostream & | operator<< (std::ostream &out, simdjson_result< padded_string > &s) noexcept(false) |
| Send padded_string instance to an output stream. | |
| std::ostream & | operator<< (std::ostream &out, simdjson_result< padded_string_view > &s) noexcept(false) |
| Send padded_string instance to an output stream. | |
| padded_string_view | pad (std::string &s) noexcept |
| Create a padded_string_view from a string. | |
| padded_string_view | pad_with_reserve (std::string &s) noexcept |
| Create a padded_string_view from a string. | |
Variables | |
| SIMDJSON_PUSH_DISABLE_UNUSED_WARNINGS constexpr size_t | SIMDJSON_MAXSIZE_BYTES = 0xFFFFFFFF |
| The maximum document size supported by simdjson. | |
| constexpr size_t | SIMDJSON_PADDING = 64 |
| The amount of padding needed in a buffer to parse JSON. | |
| constexpr size_t | DEFAULT_MAX_DEPTH = 1024 |
| By default, simdjson supports this many nested objects and arrays. | |
The top level simdjson namespace, containing everything the library provides.
We want to support argument-dependent lookup (ADL).
Hence we should define operator<< in the namespace where the argument (here value, object, etc.) resides. Credit: @madhur4127 See https://github.com/simdjson/simdjson/issues/1768
| using simdjson::ErrorValues = typedef error_code |
| anonymous enum |
Definition at line 10 of file simdjson_version.h.
| enum simdjson::error_code |
All possible errors returned by simdjson.
These error codes are subject to change and not all simdjson kernel returns the same error code given the same input: it is not well defined which error a given input should produce.
Only SUCCESS evaluates to false as a Boolean. All other error codes will evaluate to true as a Boolean.
|
strong |
This enum is used with the dom_parser_implementation::stage1 function.
1) The regular mode expects a fully formed JSON document. 2) The streaming_partial mode expects a possibly truncated input within a stream on JSON documents. 3) The stream_final mode allows us to truncate final unterminated strings. It is useful in conjunction with streaming_partial.
Definition at line 22 of file dom_parser_implementation.h.
| const implementation * simdjson::builtin_implementation | ( | ) |
Function which returns a pointer to an implementation matching the "builtin" implementation.
The builtin implementation is the best statically linked simdjson implementation that can be used by the compiling program. If you compile with g++ -march=haswell, this will return the haswell implementation. It is handy to be able to check what builtin was used: builtin_implementation()->name().
|
inlinenoexcept |
It is the convention throughout the code that the macro SIMDJSON_DEVELOPMENT_CHECKS determines whether we check for OUT_OF_ORDER_ITERATION.
The logic behind it is that these errors only occurs when the code that was written while breaking some simdjson::ondemand requirement. They should not occur in released code after these issues were fixed. Get the error message for the given error code.
dom::parser parser; dom::element doc; auto error = parser.parse("foo",3).get(doc); if (error) { printf("Error: %s\n", error_message(error)); }
Definition at line 25 of file error-inl.h.
|
inlinenoexcept |
error_code, use error_message() instead. Definition at line 32 of file error-inl.h.
|
extern |
The active implementation.
Automatically initialized on first use to the most advanced implementation supported by this hardware.
|
inline |
Definition at line 14 of file jsonioutil.h.
|
inline |
Definition at line 66 of file jsonpathutil.h.
|
inlinenoexcept |
Some errors are fatal and invalidate the document.
This function returns true if the error is fatal. It returns true for TAPE_ERROR and INCOMPLETE_ARRAY_OR_OBJECT. Once a fatal error is encountered, the on-demand document is no longer valid and processing should stop.
Definition at line 10 of file error-inl.h.
|
inline |
Returns true if mode == streaming_partial or mode == streaming_final.
Definition at line 27 of file dom_parser_implementation.h.
|
inline |
Converts JSONPath to JSON Pointer.
| json_path | The JSONPath string to be converted. |
Definition at line 15 of file jsonpathutil.h.
|
noexcept |
Minify the input string assuming that it represents a JSON string, does not parse or validate.
This function is much faster than parsing a JSON string and then writing a minified version of it. However, it does not validate the input. It will merely return an error in simple cases (e.g., if there is a string that was never terminated).
| buf | the json document to minify. |
| len | the length of the json document. |
| dst | the buffer to write the minified document to. MUST be allocated up to len bytes. |
| dst_len | the number of bytes written. Output only. |
| std::string simdjson::minify | ( | simdjson_result< T > | x | ) |
Definition at line 277 of file serialization.h.
| std::string simdjson::minify | ( | T | x | ) |
Minifies a JSON element or document, printing the smallest possible valid JSON.
dom::parser parser; element doc = parser.parse(" [ 1 , 2 , 3 ] "_padded); cout << minify(doc) << endl; // prints [1,2,3]
Definition at line 274 of file serialization.h.
|
inline |
Send padded_string instance to an output stream.
| out | The output stream. |
| s | The padded_string instance. |
| if | there is an error with the underlying output stream. simdjson itself will not throw. |
Definition at line 146 of file padded_string.h.
|
inlinenoexcept |
Write the error message to the output stream.
Definition at line 40 of file error-inl.h.
|
inline |
Send padded_string instance to an output stream.
| out | The output stream. |
| s | The padded_string instance. |
| simdjson_error | if the result being printed has an error. If there is an error with the underlying output stream, that error will be propagated (simdjson_error will not be thrown). |
Definition at line 158 of file padded_string.h.
|
inline |
Send padded_string instance to an output stream.
| out | The output stream. |
| s | The padded_string_view. |
| simdjson_error | if the result being printed has an error. If there is an error with the underlying output stream, that error will be propagated (simdjson_error will not be thrown). |
Definition at line 69 of file padded_string_view-inl.h.
|
inline |
|
inlinenoexcept |
Create a padded_string_view from a string.
The string will be padded with up to SIMDJSON_PADDING space characters. The resulting padded_string_view will have a length equal to the original string, except maybe for trailing white space characters.
| s | The string. |
Definition at line 72 of file padded_string_view-inl.h.
|
inlinenoexcept |
Create a padded_string_view from a string.
The capacity of the string will be padded with SIMDJSON_PADDING characters. The resulting padded_string_view will have a length equal to the original string.
| s | The string. |
Definition at line 91 of file padded_string_view-inl.h.
| std::string simdjson::prettify | ( | simdjson_result< T > | x | ) |
Definition at line 311 of file serialization.h.
| std::string simdjson::prettify | ( | T | x | ) |
Prettifies a JSON element or document, printing the valid JSON with indentation.
dom::parser parser; element doc = parser.parse(" [ 1 , 2 , 3 ] "_padded);
// Prints: // { // [ // 1, // 2, // 3 // ] // } cout << prettify(doc) << endl;
Definition at line 303 of file serialization.h.
| simdjson_warn_unused simdjson_result< std::string > simdjson::to_json | ( | const Z & | z, |
| size_t | initial_capacity = simdjson::SIMDJSON_IMPLEMENTATION::builder::string_builder::DEFAULT_INITIAL_CAPACITY |
||
| ) |
Definition at line 279 of file json_string_builder.h.
| simdjson_warn_unused simdjson_error simdjson::to_json | ( | const Z & | z, |
| std::string & | s, | ||
| size_t | initial_capacity = simdjson::SIMDJSON_IMPLEMENTATION::builder::string_builder::DEFAULT_INITIAL_CAPACITY |
||
| ) |
Definition at line 288 of file json_string_builder.h.
|
inlinenoexcept |
Create a string-view instance out of an array instance.
The string-view instance contains JSON text that is suitable to be parsed as JSON again. It does not validate the content.
Definition at line 83 of file serialization-inl.h.
|
inlinenoexcept |
Create a string-view instance out of a document instance.
The string-view instance contains JSON text that is suitable to be parsed as JSON again. It does not validate the content.
Definition at line 30 of file serialization-inl.h.
|
inlinenoexcept |
Definition at line 37 of file serialization-inl.h.
|
inlinenoexcept |
Create a string-view instance out of an object instance.
The string-view instance contains JSON text that is suitable to be parsed as JSON again. It does not validate the content.
Definition at line 76 of file serialization-inl.h.
|
inlinenoexcept |
Create a string-view instance out of a value instance.
The string-view instance contains JSON text that is suitable to be parsed as JSON again. The value must not have been accessed previously. It does not validate the content.
If we somehow receive a value that has already been consumed, then the following code could be in trouble. E.g., we create an array as needed, but if an array was already created, then it could be bad.
Definition at line 44 of file serialization-inl.h.
|
inline |
Definition at line 110 of file serialization-inl.h.
|
inline |
Definition at line 90 of file serialization-inl.h.
|
inline |
Definition at line 95 of file serialization-inl.h.
|
inline |
Definition at line 105 of file serialization-inl.h.
|
inline |
Definition at line 100 of file serialization-inl.h.
| std::string simdjson::to_string | ( | simdjson_result< T > | x | ) |
Definition at line 257 of file serialization.h.
| std::string simdjson::to_string | ( | T | x | ) |
Converts JSON to a string.
dom::parser parser; element doc = parser.parse(" [ 1 , 2 , 3 ] "_padded); cout << to_string(doc) << endl; // prints [1,2,3]
Definition at line 247 of file serialization.h.
|
inlinenoexcept |
Definition at line 19 of file serialization-inl.h.
|
noexcept |
Validate the UTF-8 string.
| buf | the string to validate. |
| len | the length of the string in bytes. |
|
noexcept |
Validate the UTF-8 string.
| p | the string to validate. |
Definition at line 35 of file implementation.h.
|
noexcept |
Validate the UTF-8 string.
| sv | the string_view to validate. |
Definition at line 25 of file implementation.h.
|
constexpr |
|
constexpr |
|
constexpr |
The amount of padding needed in a buffer to parse JSON.
The input buf should be readable up to buf + SIMDJSON_PADDING this is a stopgap; there should be a better description of the main loop and its behavior that abstracts over this See https://github.com/simdjson/simdjson/issues/174