json_array_len will now fail if the passed in json is not an array
This commit is contained in:
parent
0c9e840986
commit
883d72ff99
|
@ -169,7 +169,7 @@ cJSON* load_json_from_file(const char* filename) {
|
|||
}
|
||||
|
||||
size_t json_array_len(cJSON* json) {
|
||||
ASSERT_RETURN(!cJSON_IsArray(json), 0, "Tried to get the length of a non-array json element.");
|
||||
ASSERT_RETURN(cJSON_IsArray(json), 0, "Tried to get the length of a non-array json element.");
|
||||
size_t len = 0;
|
||||
cJSON* itr;
|
||||
cJSON_ArrayForEach(itr, json) {
|
||||
|
|
Loading…
Reference in a new issue