Commit 223524d5 authored by Mikaël Salson's avatar Mikaël Salson Committed by Vidjil Team
Browse files

vidjil_utils: extract_fields_from_json: make sure the value exists before accessing it.

parent 837e80fc
...@@ -175,10 +175,11 @@ def extract_fields_from_json(json_fields, pos_in_list, filename): ...@@ -175,10 +175,11 @@ def extract_fields_from_json(json_fields, pos_in_list, filename):
matched_keys = {} matched_keys = {}
for field in json_fields: for field in json_fields:
value = extract_value_from_json_path(json_fields[field], json_dict) value = extract_value_from_json_path(json_fields[field], json_dict)
if not isinstance(value, basestring): if value is not None:
matched_keys[field] = value[pos_in_list] if not isinstance(value, basestring) and len(value) > pos_in_list:
else: matched_keys[field] = value[pos_in_list]
matched_keys[field] = value else:
matched_keys[field] = value
return matched_keys return matched_keys
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment