MCPcopy Create free account
hub / github.com/antirez/botlib / get_object_item

Function get_object_item

cJSON.c:1876–1906  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1874}
1875
1876static cJSON *get_object_item(const cJSON * const object, const char * const name, const cJSON_bool case_sensitive)
1877{
1878 cJSON *current_element = NULL;
1879
1880 if ((object == NULL) || (name == NULL))
1881 {
1882 return NULL;
1883 }
1884
1885 current_element = object->child;
1886 if (case_sensitive)
1887 {
1888 while ((current_element != NULL) && (current_element->string != NULL) && (strcmp(name, current_element->string) != 0))
1889 {
1890 current_element = current_element->next;
1891 }
1892 }
1893 else
1894 {
1895 while ((current_element != NULL) && (case_insensitive_strcmp((const unsigned char*)name, (const unsigned char*)(current_element->string)) != 0))
1896 {
1897 current_element = current_element->next;
1898 }
1899 }
1900
1901 if ((current_element == NULL) || (current_element->string == NULL)) {
1902 return NULL;
1903 }
1904
1905 return current_element;
1906}
1907
1908CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string)
1909{

Callers 4

cJSON_GetObjectItemFunction · 0.85
replace_item_in_objectFunction · 0.85
cJSON_CompareFunction · 0.85

Calls 1

case_insensitive_strcmpFunction · 0.85

Tested by

no test coverage detected