Fix bug with ?_nl=on and binary data, closes #914

This commit is contained in:
Simon Willison 2020-08-16 11:24:39 -07:00
commit 8e7e6458a6
4 changed files with 40 additions and 5 deletions

View file

@ -84,7 +84,7 @@ def json_renderer(args, data, view_name):
# Handle _nl option for _shape=array
nl = args.get("_nl", "")
if nl and shape == "array":
body = "\n".join(json.dumps(item) for item in data)
body = "\n".join(json.dumps(item, cls=CustomJSONEncoder) for item in data)
content_type = "text/plain"
else:
body = json.dumps(data, cls=CustomJSONEncoder)