diff --git a/CHANGES.txt b/CHANGES.txt index e7fbd83a9a6c1a83383a70383f7e25b282c3195c_Q0hBTkdFUy50eHQ=..6e8dc56c01018389a23a49977f58a370df1f06a5_Q0hBTkdFUy50eHQ= 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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 diff --git a/simplejson/encoder.py b/simplejson/encoder.py index e7fbd83a9a6c1a83383a70383f7e25b282c3195c_c2ltcGxlanNvbi9lbmNvZGVyLnB5..6e8dc56c01018389a23a49977f58a370df1f06a5_c2ltcGxlanNvbi9lbmNvZGVyLnB5 100644 --- a/simplejson/encoder.py +++ b/simplejson/encoder.py @@ -165,6 +165,8 @@ 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 diff --git a/simplejson/tests/test_indent.py b/simplejson/tests/test_indent.py index e7fbd83a9a6c1a83383a70383f7e25b282c3195c_c2ltcGxlanNvbi90ZXN0cy90ZXN0X2luZGVudC5weQ==..6e8dc56c01018389a23a49977f58a370df1f06a5_c2ltcGxlanNvbi90ZXN0cy90ZXN0X2luZGVudC5weQ== 100644 --- a/simplejson/tests/test_indent.py +++ b/simplejson/tests/test_indent.py @@ -67,3 +67,20 @@ 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)) \ No newline at end of file