28
28
Compact encoding::
29
29
30
30
>>> import json
31
- >>> from collections import OrderedDict
32
- >>> mydict = OrderedDict([('4', 5), ('6', 7)])
31
+ >>> mydict = {'4': 5, '6': 7}
33
32
>>> json.dumps([1,2,3,mydict], separators=(',', ':'))
34
33
'[1,2,3,{"4":5,"6":7}]'
35
34
@@ -285,14 +284,11 @@ def load(fp, *, cls=None, object_hook=None, parse_float=None,
285
284
``object_pairs_hook`` is an optional function that will be called with the
286
285
result of any object literal decoded with an ordered list of pairs. The
287
286
return value of ``object_pairs_hook`` will be used instead of the ``dict``.
288
- This feature can be used to implement custom decoders that rely on the
289
- order that the key and value pairs are decoded (for example,
290
- collections.OrderedDict will remember the order of insertion). If
291
- ``object_hook`` is also defined, the ``object_pairs_hook`` takes priority.
287
+ This feature can be used to implement custom decoders. If ``object_hook``
288
+ is also defined, the ``object_pairs_hook`` takes priority.
292
289
293
290
To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
294
291
kwarg; otherwise ``JSONDecoder`` is used.
295
-
296
292
"""
297
293
return loads (fp .read (),
298
294
cls = cls , object_hook = object_hook ,
@@ -313,10 +309,8 @@ def loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None,
313
309
``object_pairs_hook`` is an optional function that will be called with the
314
310
result of any object literal decoded with an ordered list of pairs. The
315
311
return value of ``object_pairs_hook`` will be used instead of the ``dict``.
316
- This feature can be used to implement custom decoders that rely on the
317
- order that the key and value pairs are decoded (for example,
318
- collections.OrderedDict will remember the order of insertion). If
319
- ``object_hook`` is also defined, the ``object_pairs_hook`` takes priority.
312
+ This feature can be used to implement custom decoders. If ``object_hook``
313
+ is also defined, the ``object_pairs_hook`` takes priority.
320
314
321
315
``parse_float``, if specified, will be called with the string
322
316
of every JSON float to be decoded. By default this is equivalent to
@@ -337,7 +331,6 @@ def loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None,
337
331
kwarg; otherwise ``JSONDecoder`` is used.
338
332
339
333
The ``encoding`` argument is ignored and deprecated.
340
-
341
334
"""
342
335
if isinstance (s , str ):
343
336
if s .startswith ('\ufeff ' ):
0 commit comments