66#include " simdjson/parsedjson.h"
77#include " simdjson/stage1_find_marks.h"
88#include " simdjson/stage2_build_tape.h"
9-
10-
11-
9+ #include " simdjson/simdjson.h"
1210
1311// Parse a document found in buf, need to preallocate ParsedJson.
14- // Return false in case of a failure. You can also check validity
15- // by calling pj.isValid(). The same ParsedJson can be reused for other documents.
12+ // Return 0 on success, an error code from simdjson/simdjson.h otherwise
13+ // You can also check validit by calling pj.isValid(). The same ParsedJson can be reused for other documents.
1614//
1715// If reallocifneeded is true (default) then a temporary buffer is created when needed during processing
1816// (a copy of the input string is made).
1917// The input buf should be readable up to buf + len + SIMDJSON_PADDING if reallocifneeded is false,
2018// all bytes at and after buf + len are ignored (can be garbage).
2119WARN_UNUSED
22- bool json_parse (const uint8_t *buf, size_t len, ParsedJson &pj, bool reallocifneeded = true );
20+ int json_parse (const uint8_t *buf, size_t len, ParsedJson &pj, bool reallocifneeded = true );
2321
2422// Parse a document found in buf, need to preallocate ParsedJson.
2523// Return false in case of a failure. You can also check validity
@@ -30,7 +28,7 @@ bool json_parse(const uint8_t *buf, size_t len, ParsedJson &pj, bool reallocifne
3028// The input buf should be readable up to buf + len + SIMDJSON_PADDING if reallocifneeded is false,
3129// all bytes at and after buf + len are ignored (can be garbage).
3230WARN_UNUSED
33- inline bool json_parse (const char * buf, size_t len, ParsedJson &pj, bool reallocifneeded = true ) {
31+ inline int json_parse (const char * buf, size_t len, ParsedJson &pj, bool reallocifneeded = true ) {
3432 return json_parse (reinterpret_cast <const uint8_t *>(buf), len, pj, reallocifneeded);
3533}
3634
@@ -43,7 +41,7 @@ inline bool json_parse(const char * buf, size_t len, ParsedJson &pj, bool reallo
4341// the input s should be readable up to s.data() + s.size() + SIMDJSON_PADDING if reallocifneeded is false,
4442// all bytes at and after s.data()+s.size() are ignored (can be garbage).
4543WARN_UNUSED
46- inline bool json_parse (const std::string_view &s, ParsedJson &pj, bool reallocifneeded = true ) {
44+ inline int json_parse (const std::string_view &s, ParsedJson &pj, bool reallocifneeded = true ) {
4745 return json_parse (s.data (), s.size (), pj, reallocifneeded);
4846}
4947
0 commit comments