aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShadab Zafar <dufferzafar0@gmail.com>2016-03-04 01:05:35 +0530
committerShadab Zafar <dufferzafar0@gmail.com>2016-03-04 01:05:35 +0530
commit9540ede11222cf1e0d796d34b82481173405c520 (patch)
treec4a1feb1a6d1fa417da85cf93f134b1bbff5e34d
parent01a99f2b252c2a4b467d26c795173a026df6d4d7 (diff)
downloadmitmproxy-9540ede11222cf1e0d796d34b82481173405c520.tar.gz
mitmproxy-9540ede11222cf1e0d796d34b82481173405c520.tar.bz2
mitmproxy-9540ede11222cf1e0d796d34b82481173405c520.zip
Use separators param in json.dumps() to avoid trailing whitespace
-rw-r--r--mitmproxy/flow_export.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/mitmproxy/flow_export.py b/mitmproxy/flow_export.py
index 49e2d704..6333de57 100644
--- a/mitmproxy/flow_export.py
+++ b/mitmproxy/flow_export.py
@@ -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: