From 1479637976000fa9bf088f2993e10d3e5ef19b40 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 1 Aug 2022 23:39:56 +0200 Subject: [PATCH] feat: add cJSON_GetErrorPos --- cJSON.c | 5 +++++ cJSON.h | 1 + 2 files changed, 6 insertions(+) diff --git a/cJSON.c b/cJSON.c index 524ba46..2ad5d01 100644 --- a/cJSON.c +++ b/cJSON.c @@ -91,6 +91,11 @@ typedef struct { } error; static error global_error = { NULL, 0 }; +CJSON_PUBLIC(size_t) cJSON_GetErrorPos(void) +{ + return global_error.position; +} + CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void) { return (const char*) (global_error.json + global_error.position); diff --git a/cJSON.h b/cJSON.h index 95a9cf6..51a505a 100644 --- a/cJSON.h +++ b/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); /* 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(size_t) cJSON_GetErrorPos(void); /* Check item type and return its value */ CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item);