mirror of
https://github.com/json-c/json-c.git
synced 2026-04-05 21:39:06 +08:00
Add json_tokener_get_error() and json_tokener_error_desc() to better encapsulate the process of retrieving errors while parsing.
Add documentation for the json_tokener_parse_ex() function.
This commit is contained in:
@@ -43,6 +43,7 @@ static const char* json_null_str = "null";
|
||||
static const char* json_true_str = "true";
|
||||
static const char* json_false_str = "false";
|
||||
|
||||
// XXX after v0.10 this array will become static:
|
||||
const char* json_tokener_errors[] = {
|
||||
"success",
|
||||
"continue",
|
||||
@@ -60,6 +61,18 @@ const char* json_tokener_errors[] = {
|
||||
"expected comment",
|
||||
};
|
||||
|
||||
const char *json_tokener_error_desc(enum json_tokener_error jerr)
|
||||
{
|
||||
if (jerr < 0 || jerr > sizeof(json_tokener_errors))
|
||||
return "Unknown error, invalid json_tokener_error value passed to json_tokener_error_desc()";
|
||||
return json_tokener_errors[jerr];
|
||||
}
|
||||
|
||||
enum json_tokener_error json_tokener_get_error(json_tokener *tok)
|
||||
{
|
||||
return tok->err;
|
||||
}
|
||||
|
||||
/* Stuff for decoding unicode sequences */
|
||||
#define IS_HIGH_SURROGATE(uc) (((uc) & 0xFC00) == 0xD800)
|
||||
#define IS_LOW_SURROGATE(uc) (((uc) & 0xFC00) == 0xDC00)
|
||||
|
||||
Reference in New Issue
Block a user