Get Array size/item / object item. */
| 1897 | |
| 1898 | /* Get Array size/item / object item. */ |
| 1899 | CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array) |
| 1900 | { |
| 1901 | cJSON *child = NULL; |
| 1902 | size_t size = 0; |
| 1903 | |
| 1904 | if (array == NULL) |
| 1905 | { |
| 1906 | return 0; |
| 1907 | } |
| 1908 | |
| 1909 | child = array->child; |
| 1910 | |
| 1911 | while(child != NULL) |
| 1912 | { |
| 1913 | size++; |
| 1914 | child = child->next; |
| 1915 | } |
| 1916 | |
| 1917 | /* FIXME: Can overflow here. Cannot be fixed without breaking the API */ |
| 1918 | |
| 1919 | return (int)size; |
| 1920 | } |
| 1921 | |
| 1922 | static cJSON* get_array_item(const cJSON *array, size_t index) |
| 1923 | { |