Commit a9cbe9d7 authored by olavhdi's avatar olavhdi
Browse files

#33 workouts/parsers

parent 1538a5ab
Pipeline #127926 failed with stage
in 27 seconds
......@@ -25,10 +25,7 @@ class MultipartJsonParser(parsers.MultiPartParser):
data[key] = value
continue
if "{" in value or "[" in value:
try:
data[key] = json.loads(value)
except ValueError:
data[key] = value
data[key] = get_key(value)
else:
data[key] = value
......@@ -37,3 +34,14 @@ class MultipartJsonParser(parsers.MultiPartParser):
new_files["files"].append({"file": file})
return parsers.DataAndFiles(data, new_files)
def get_key(value):
"""
Tries to fetch a key from the dataset
"""
try:
key = json.loads(value)
except ValueError:
key = value
return key
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