Use separators param in json.dumps() to avoid trailing whitespace

This commit is contained in:
Shadab Zafar 2016-03-04 01:05:35 +05:30
parent 01a99f2b25
commit 9540ede112

View File

@ -58,7 +58,9 @@ def python_code(flow):
if flow.request.body:
json_obj = is_json(flow.request.headers, flow.request.body)
if json_obj:
data = json.dumps(json_obj, indent=4)
# Without the separators field json.dumps() produces
# trailing white spaces: https://bugs.python.org/issue16333
data = json.dumps(json_obj, indent=4, separators=(',', ': '))
data = "\njson = %s\n" % data
args += "\n json=json,"
else: