Permalink
Showing with 20 additions and 0 deletions.
  1. +1 −0 CHANGES.txt
  2. +2 −0 simplejson/encoder.py
  3. +17 −0 simplejson/tests/test_indent.py
View
@@ -1,5 +1,6 @@
Version 2.1.4 released XXXX-XX-XX
+* Trailing whitespace after commas no longer emitted when indent is used
* Migrated to github http://github.com/simplejson/simplejson
Version 2.1.3 released 2011-01-17
View
@@ -165,6 +165,8 @@ def __init__(self, skipkeys=False, ensure_ascii=True,
self.indent = indent
if separators is not None:
self.item_separator, self.key_separator = separators
+ elif indent is not None:
+ self.item_separator = ','
if default is not None:
self.default = default
self.encoding = encoding
@@ -67,3 +67,20 @@ def check(indent, expected):
check(0, '{\n"3": 1\n}')
# indent=None is more compact
check(None, '{"3": 1}')
+
+ def test_separators(self):
+ lst = [1,2,3,4]
+ expect = '[\n1,\n2,\n3,\n4\n]'
+ expect_spaces = '[\n1, \n2, \n3, \n4\n]'
+ # Ensure that separators still works
+ self.assertEquals(
+ expect_spaces,
+ json.dumps(lst, indent=0, separators=(', ', ': ')))
+ # Force the new defaults
+ self.assertEquals(
+ expect,
+ json.dumps(lst, indent=0, separators=(',', ': ')))
+ # Added in 2.1.4
+ self.assertEquals(
+ expect,
+ json.dumps(lst, indent=0))

0 comments on commit 5cad556

Please sign in to comment.