From 605422c60acb2be2c33e25c9b9a5fa7a83335a68 Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Tue, 21 Feb 2017 10:43:43 +0100 Subject: [PATCH] cJSON: New function cJSON_GetObjectItemCaseSensitive --- cJSON.c | 18 ++++++++++++++++++ cJSON.h | 1 + 2 files changed, 19 insertions(+) diff --git a/cJSON.c b/cJSON.c index 46187c6..dddc1af 100644 --- a/cJSON.c +++ b/cJSON.c @@ -1466,6 +1466,24 @@ cJSON *cJSON_GetObjectItem(const cJSON *object, const char *string) return c; } +cJSON *cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string) +{ + cJSON *current_element = NULL; + + if ((object == NULL) || (string == NULL)) + { + return NULL; + } + + current_element = object->child; + while ((current_element != NULL) && (strcmp(string, current_element->string) != 0)) + { + current_element = current_element->next; + } + + return current_element; +} + cjbool cJSON_HasObjectItem(const cJSON *object, const char *string) { return cJSON_GetObjectItem(object, string) ? 1 : 0; diff --git a/cJSON.h b/cJSON.h index 88c9130..de1f69f 100644 --- a/cJSON.h +++ b/cJSON.h @@ -104,6 +104,7 @@ extern int cJSON_GetArraySize(const cJSON *array); extern cJSON *cJSON_GetArrayItem(const cJSON *array, int item); /* Get item "string" from object. Case insensitive. */ extern cJSON *cJSON_GetObjectItem(const cJSON *object, const char *string); +extern cJSON *cJSON_GetObjectItemCaseSensitive(const cJSON *object, const char *string); extern int 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. */ extern const char *cJSON_GetErrorPtr(void);