MCPcopy Index your code
hub / github.com/DaveGamble/cJSON / get_object_item

Function get_object_item

cJSON.c:1936–1966  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1934}
1935
1936static cJSON *get_object_item(const cJSON * const object, const char * const name, const cJSON_bool case_sensitive)
1937{
1938 cJSON *current_element = NULL;
1939
1940 if ((object == NULL) || (name == NULL))
1941 {
1942 return NULL;
1943 }
1944
1945 current_element = object->child;
1946 if (case_sensitive)
1947 {
1948 while ((current_element != NULL) && (current_element->string != NULL) && (strcmp(name, current_element->string) != 0))
1949 {
1950 current_element = current_element->next;
1951 }
1952 }
1953 else
1954 {
1955 while ((current_element != NULL) && (case_insensitive_strcmp((const unsigned char*)name, (const unsigned char*)(current_element->string)) != 0))
1956 {
1957 current_element = current_element->next;
1958 }
1959 }
1960
1961 if ((current_element == NULL) || (current_element->string == NULL)) {
1962 return NULL;
1963 }
1964
1965 return current_element;
1966}
1967
1968CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string)
1969{

Callers 4

cJSON_GetObjectItemFunction · 0.70
replace_item_in_objectFunction · 0.70
cJSON_CompareFunction · 0.70

Calls 1

case_insensitive_strcmpFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…