Add custom separators support to JSONRenderer

Allow custom separators for the JSONRenderer  by sending a 'separators' item in your
`renderer_context`.
This commit is contained in:
William Stewart 2015-01-19 11:43:58 +02:00
parent 4f27b966a5
commit d8ee1389b8

View File

@ -90,7 +90,9 @@ class JSONRenderer(BaseRenderer):
renderer_context = renderer_context or {}
indent = self.get_indent(accepted_media_type, renderer_context)
separators = SHORT_SEPARATORS if (indent is None and self.compact) else LONG_SEPARATORS
separators = renderer_context.get(
'separators',
SHORT_SEPARATORS if (indent is None and self.compact) else LONG_SEPARATORS)
ret = json.dumps(
data, cls=self.encoder_class,