mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
feat: add cJSON_GetErrorPos
This commit is contained in:
parent
b45f48e600
commit
1479637976
5
cJSON.c
5
cJSON.c
@ -91,6 +91,11 @@ typedef struct {
|
|||||||
} error;
|
} error;
|
||||||
static error global_error = { NULL, 0 };
|
static error global_error = { NULL, 0 };
|
||||||
|
|
||||||
|
CJSON_PUBLIC(size_t) cJSON_GetErrorPos(void)
|
||||||
|
{
|
||||||
|
return global_error.position;
|
||||||
|
}
|
||||||
|
|
||||||
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void)
|
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void)
|
||||||
{
|
{
|
||||||
return (const char*) (global_error.json + global_error.position);
|
return (const char*) (global_error.json + global_error.position);
|
||||||
|
1
cJSON.h
1
cJSON.h
@ -174,6 +174,7 @@ CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const objec
|
|||||||
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
|
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
|
||||||
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
||||||
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
|
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
|
||||||
|
CJSON_PUBLIC(size_t) cJSON_GetErrorPos(void);
|
||||||
|
|
||||||
/* Check item type and return its value */
|
/* Check item type and return its value */
|
||||||
CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item);
|
CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item);
|
||||||
|
Loading…
Reference in New Issue
Block a user