Try to load strings as JSON

This commit is contained in:
Sean Hammond 2012-02-29 20:37:57 +01:00
parent 1a88ae647e
commit d1f10a6d46

View File

@ -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