You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JSONParser.parse() calls self.parse_json_dict(json_dict) which eventually tries for key, value in json_dict.items():, which can raise: AttributeError("'list' object has no attribute 'items'")
For example, if a user accidentally double-wraps OCDS releases in arrays:
{
"releases": [[
{"id": "1"}
]]
}
My preference would be something like:
fromflattentool.exceptionsimportDataErrorWarning# ...classJSONParser(object):
# ...defparse(self):
fornum, json_dictinenumerate(self.root_json_list):
ifjson_dictisNone:
# This is particularly useful for IATI XML, in order to not# fall over on empty activity, e.g. <iati-activity/>continue# NEW CODEifnotisinstance(json_dict, dict):
warn(_(f"The value at index {num} is not a JSON object"), DataErrorWarning)
continue
JSONParser.parse()
callsself.parse_json_dict(json_dict)
which eventually triesfor key, value in json_dict.items():
, which can raise:AttributeError("'list' object has no attribute 'items'")
For example, if a user accidentally double-wraps OCDS
releases
in arrays:My preference would be something like:
Related: #398
The text was updated successfully, but these errors were encountered: