let's say I have this json-array :
"test": { "d": "med", "min": [ "low","med","high"]}
now using json-c api I want to remove the high
string from the key min
.
int arrLen=json_object_array_length(test_array_min);
int j=0;
json_object *high_ptr = NULL;
for ( j = 0; j < arrLen; j++)
{
high_ptr = json_object_array_get_idx(test_array_min, j);
clog_debug(NULL, "array[%d] : %s", j,json_object_to_json_string(high_ptr));
if(!strcmp(json_object_get_string(high_ptr), "high")) {
json_object_array_del_idx((test_array_min),(j),1);
break;
}
}
but this fails, even though I can see clearly I am pointing to the right json field of high when I print it's string value. what am I doing wrong?
looking for json-c api, looking at examples how to remove element from json-c array.