mirror of
https://github.com/httpie/cli.git
synced 2025-02-16 17:40:51 +01:00
Try to load strings as JSON
This commit is contained in:
parent
1a88ae647e
commit
d1f10a6d46
@ -125,6 +125,11 @@ def main():
|
||||
# JSON/Form content type.
|
||||
if args.json or (not args.form and data):
|
||||
if sys.stdin.isatty():
|
||||
for key, value in data.items():
|
||||
try:
|
||||
data[key] = json.loads(value)
|
||||
except ValueError:
|
||||
pass
|
||||
data = json.dumps(data)
|
||||
if 'Content-Type' not in headers and (data or args.json):
|
||||
headers['Content-Type'] = TYPE_JSON
|
||||
|
Loading…
Reference in New Issue
Block a user