https://github.com/python/cpython/commit/a64d7e1d6b3595b10655e3ac12930a741541dab2 commit: a64d7e1d6b3595b10655e3ac12930a741541dab2 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: nedbat <[email protected]> date: 2026-09-21T06:57:55-04:00 summary:
[3.13] gh-157571: Move json sort note from dumps to dump (GH-157577) (#157895) gh-157571: Move json sort note from dumps to dump (GH-157577) * gh-157571: Move json sort note from dumps to dump * "coerce" is not a Python term. --------- (cherry picked from commit b426caa04b1e165d4054125e67ee6c74141910a4) Signed-off-by: MeGaurav4 <[email protected]> Co-authored-by: Gaurav Yadav <[email protected]> Co-authored-by: Ned Batchelder <[email protected]> files: M Doc/library/json.rst diff --git a/Doc/library/json.rst b/Doc/library/json.rst index 48a2a8e4797acb..3796f63e5b2c71 100644 --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -237,6 +237,16 @@ Basic Usage If ``True``, dictionaries will be outputted sorted by key. Default ``False``. + .. note:: + + Keys in key/value pairs of JSON are always of the type :class:`str`. When + a dictionary is converted into JSON, all the keys of the dictionary are + converted to strings. As a result of this, if a dictionary is converted + into JSON and then back into a dictionary, the dictionary may not equal + the original one. That is, ``loads(dumps(x)) != x`` if x has non-string + keys. *sort_keys* sorts the keys before they are converted to strings, + so numeric keys are sorted by value, not by their string representation. + .. versionchanged:: 3.2 Allow strings for *indent* in addition to integers. @@ -256,17 +266,6 @@ Basic Usage table <py-to-json-table>`. The arguments have the same meaning as in :func:`dump`. - .. note:: - - Keys in key/value pairs of JSON are always of the type :class:`str`. When - a dictionary is converted into JSON, all the keys of the dictionary are - coerced to strings. As a result of this, if a dictionary is converted - into JSON and then back into a dictionary, the dictionary may not equal - the original one. That is, ``loads(dumps(x)) != x`` if x has non-string - keys. - *sort_keys* sorts the keys before they are coerced to strings, - so numeric keys are sorted by value, not by their string representation. - .. function:: load(fp, *, cls=None, object_hook=None, parse_float=None, \ parse_int=None, parse_constant=None, \ object_pairs_hook=None, **kw) _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
