kgabis/parson

What if enclosingn [] is missing?

ad1c opened this issue · 3 comments

ad1c commented

I am trying to use parson to parse a JSON file that does not have the starting '[' and ending ']'. It simply starts like the following.

{
"contents": "Invalid Operations, Bad Spots",
"entries": [
{
"band": "",
"callsign": "3A/IK4FXX",
"category": "I",
"endOn": "",
"entity": "3A",
"mode": "",
"name": "Monaco",
"notes": "No such call",
"startOn": "2023-01-28",
"zone": ""
}
}

Here is part of my code:

root_value = json_parse_file(fileName);
if (json_value_get_type(root_value) != JSONArray) {
fprintf(stderr,"bad json file\n");
exit(1);
}

The test above is failing, causing the program to exit. What function do I need to make this work without modifying the JSON file?

You are parsing a json object, not a json array.

ad1c commented

Thank you.