simdjson
3.11.0
Ridiculously Fast JSON
|
The top level simdjson namespace, containing everything the library provides. More...
Namespaces | |
arm64 | |
Implementation for NEON (ARMv8). | |
dom | |
A DOM API on top of the simdjson parser. | |
fallback | |
Fallback implementation (runs on any machine). | |
haswell | |
Implementation for Haswell (Intel AVX2). | |
icelake | |
Implementation for Icelake (Intel AVX512). | |
lasx | |
Implementation for LASX. | |
lsx | |
Implementation for LSX. | |
ppc64 | |
Implementation for ALTIVEC (PPC64). | |
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 , 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 = 3 , SIMDJSON_VERSION_MINOR = 11 , SIMDJSON_VERSION_REVISION = 0 } |
Functions | |
const implementation * | builtin_implementation () |
Function which returns a pointer to an implementation matching the "builtin" implementation. More... | |
template<class T > | |
std::string | to_string (T x) |
Converts JSON to a string. More... | |
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. More... | |
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. More... | |
template<class T > | |
std::string | prettify (simdjson_result< T > x) |
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. More... | |
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) |
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. More... | |
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. More... | |
simdjson_result< std::string_view > | to_json_string (SIMDJSON_IMPLEMENTATION::ondemand::object &x) noexcept |
Create a string-view instance out of an object instance. More... | |
simdjson_result< std::string_view > | to_json_string (SIMDJSON_IMPLEMENTATION::ondemand::array &x) noexcept |
Create a string-view instance out of an array instance. More... | |
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. More... | |
simdjson_inline simdjson_warn_unused bool | validate_utf8 (const std::string_view sv) noexcept |
Validate the UTF-8 string. More... | |
simdjson_inline simdjson_warn_unused bool | validate_utf8 (const std::string &s) noexcept |
Validate the UTF-8 string. More... | |
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. More... | |
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. More... | |
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. More... | |
std::ostream & | operator<< (std::ostream &out, const padded_string &s) |
Send padded_string instance to an output stream. More... | |
std::ostream & | operator<< (std::ostream &out, simdjson_result< padded_string > &s) noexcept(false) |
Send padded_string instance to an output stream. More... | |
std::ostream & | operator<< (std::ostream &out, simdjson_result< padded_string_view > &s) noexcept(false) |
Send padded_string instance to an output stream. More... | |
padded_string_view | pad (std::string &s) noexcept |
Create a padded_string_view from a string. More... | |
Variables | |
constexpr SIMDJSON_PUSH_DISABLE_UNUSED_WARNINGS 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. More... | |
constexpr size_t | DEFAULT_MAX_DEPTH = 1024 |
By default, simdjson supports this many nested objects and arrays. More... | |
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 20 of file error-inl.h.
|
inlinenoexcept |
error_code
, use error_message()
instead.Definition at line 27 of file error-inl.h.
SIMDJSON_DLLIMPORTEXPORT internal::atomic_ptr<const implementation>& simdjson::get_active_implementation | ( | ) |
The active implementation.
Automatically initialized on first use to the most advanced implementation supported by this hardware.
|
inline |
Converts JSONPath to JSON Pointer.
json_path | The JSONPath string to be converted. |
Definition at line 13 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 | ( | 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 212 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 |
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.
|
inlinenoexcept |
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 53 of file padded_string_view-inl.h.
|
inlinenoexcept |
Create a padded_string_view from a string.
The string will be padded with SIMDJSON_PADDING space characters. The resulting padded_string_view will have a length equal to the original string.
s | The string. |
Definition at line 56 of file padded_string_view-inl.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 242 of file serialization.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 80 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 27 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 73 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 41 of file serialization-inl.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 186 of file serialization.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 |
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