提交 605422c6 编写于 作者: M Max Bruckner

cJSON: New function cJSON_GetObjectItemCaseSensitive

上级 cbbcc914
...@@ -1466,6 +1466,24 @@ cJSON *cJSON_GetObjectItem(const cJSON *object, const char *string) ...@@ -1466,6 +1466,24 @@ cJSON *cJSON_GetObjectItem(const cJSON *object, const char *string)
return c; 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) cjbool cJSON_HasObjectItem(const cJSON *object, const char *string)
{ {
return cJSON_GetObjectItem(object, string) ? 1 : 0; return cJSON_GetObjectItem(object, string) ? 1 : 0;
......
...@@ -104,6 +104,7 @@ extern int cJSON_GetArraySize(const cJSON *array); ...@@ -104,6 +104,7 @@ extern int cJSON_GetArraySize(const cJSON *array);
extern cJSON *cJSON_GetArrayItem(const cJSON *array, int item); extern cJSON *cJSON_GetArrayItem(const cJSON *array, int item);
/* Get item "string" from object. Case insensitive. */ /* Get item "string" from object. Case insensitive. */
extern cJSON *cJSON_GetObjectItem(const cJSON *object, const char *string); 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); 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. */ /* 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); extern const char *cJSON_GetErrorPtr(void);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册