mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
* Fix-up a TODO (support the sort_key option).
* Fix an error where True/False were being written-out as title-cased strings when used a dictionary keys. * Speed-up iteration over dicts by looping over items() rather than keys() followed by value lookups. * TODO: sort only by keys, not keys and values.
This commit is contained in:
parent
81c0dcee65
commit
bcf6f92dc5
3 changed files with 47 additions and 22 deletions
|
@ -43,3 +43,8 @@ class TestEncodeBaseStringAscii(TestCase):
|
|||
items = [('one', 1), ('two', 2), ('three', 3), ('four', 4), ('five', 5)]
|
||||
s = json.dumps(OrderedDict(items))
|
||||
self.assertEqual(s, '{"one": 1, "two": 2, "three": 3, "four": 4, "five": 5}')
|
||||
|
||||
def test_sorted_dict(self):
|
||||
items = [('one', 1), ('two', 2), ('three', 3), ('four', 4), ('five', 5)]
|
||||
s = json.dumps(dict(items), sort_keys=True)
|
||||
self.assertEqual(s, '{"five": 5, "four": 4, "one": 1, "three": 3, "two": 2}')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue