Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Håvard Farestveit
tdt4242-base
Commits
a9cbe9d7
Commit
a9cbe9d7
authored
Apr 14, 2021
by
olavhdi
Browse files
#33
workouts/parsers
parent
1538a5ab
Pipeline
#127926
failed with stage
in 27 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
backend/secfit/workouts/parsers.py
View file @
a9cbe9d7
...
...
@@ -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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment