Commit 223524d5 authored by Mikael Salson's avatar Mikael Salson Committed by Vidjil Team

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):
matched_keys = {}
for field in json_fields:
value = extract_value_from_json_path(json_fields[field], json_dict)
if not isinstance(value, basestring):
matched_keys[field] = value[pos_in_list]
else:
matched_keys[field] = value
if value is not None:
if not isinstance(value, basestring) and len(value) > pos_in_list:
matched_keys[field] = value[pos_in_list]
else:
matched_keys[field] = value
return matched_keys
......
Markdown is supported
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