MySQL 9.1.0
Source Code Documentation
|
#include "sql-common/json_syntax_check.h"
#include <assert.h>
#include <string>
#include <utility>
#include "my_rapidjson_size_t.h"
#include <rapidjson/error/en.h>
#include <rapidjson/error/error.h>
#include <rapidjson/memorystream.h>
#include <rapidjson/reader.h>
Functions | |
bool | is_valid_json_syntax (const char *text, size_t length, size_t *error_offset, std::string *error_message, const JsonErrorHandler &depth_handler) |
Check if a string is a valid JSON. More... | |
bool | check_json_depth (size_t depth, const JsonErrorHandler &handler) |
Check if the depth of a JSON document exceeds the maximum supported depth (JSON_DOCUMENT_MAX_DEPTH). More... | |
bool | check_json_depth (size_t depth, const JsonSerializationErrorHandler &handler) |
std::pair< std::string, size_t > | get_error_from_reader (const rapidjson::Reader &reader) |
Extract a readable error from a rapidjson reader and return it to the caller. More... | |
Variables | |
static constexpr int | JSON_DOCUMENT_MAX_DEPTH = 100 |
The maximum number of nesting levels allowed in a JSON document. More... | |
bool check_json_depth | ( | size_t | depth, |
const JsonErrorHandler & | handler | ||
) |
Check if the depth of a JSON document exceeds the maximum supported depth (JSON_DOCUMENT_MAX_DEPTH).
Raise an error if the maximum depth has been exceeded.
[in] | depth | the current depth of the document |
[in] | handler | callback function that gets called when maximum depth is exceeded |
bool check_json_depth | ( | size_t | depth, |
const JsonSerializationErrorHandler & | handler | ||
) |
std::pair< std::string, size_t > get_error_from_reader | ( | const rapidjson::Reader & | reader | ) |
Extract a readable error from a rapidjson reader and return it to the caller.
[in] | reader | The rapidjson reader to extract the error from. |
bool is_valid_json_syntax | ( | const char * | text, |
size_t | length, | ||
size_t * | error_offset, | ||
std::string * | error_message, | ||
const JsonErrorHandler & | depth_handler | ||
) |
Check if a string is a valid JSON.
[in] | text | A pointer to the start of the text |
[in] | length | The length of the text |
[out] | error_offset | If the text is not a valid JSON, this variable will be set to the position in the input string where the error occurred. Can be nullptr. |
[out] | error_message | If the text is not a valid JSON, this variable will contain a readable error message. Can be nullptr. |
[in] | depth_handler | Pointer to a function that should handle error occurred when depth is exceeded. |
true | if the input text is a valid JSON. |
false | if the input text is not a valid JSON. |
|
staticconstexpr |
The maximum number of nesting levels allowed in a JSON document.