kgabis/parson

clublog-users.json.zip

ad1c opened this issue · 1 comments

ad1c commented

I have used this library with success before, but I can't seem to parse the JSON file inside this ZIP file:

https://secure.clublog.org/clublog-users.json.zip

Here is my code. Is there something wrong with the format of the .json file? It is not enclosed by [] but json_parse_file seems to return a non-null JSON_Value.

call_t *read_json_members(HWND hwnd, FILE *input, call_t *root, update_t *update, char mbr_id)
{
JSON_Value *root_value;
JSON_Array *events;
int num_events;
JSON_Value *value;

const char *event_data[3];

root_value = json_parse_file(update->targetPath);

events = json_value_get_array(root_value);
num_events = json_array_get_count(events);

return root;
}

Root value is a json object, not an array, so you should be doing something like:

JSON_Value *root_value = json_parse_file(update->targetPath);
assert(root_value);
JSON_Object *events = json_value_get_object(root_value);
assert(events);
num_events = json_object_get_count(events);