Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.13] gh-134150: Clarify distinction between JSON and Python objects (GH-134154)#134167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nedbat merged 1 commit intopython:3.13frommiss-islington:backport-fa4e088-3.13
May 18, 2025
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-134150: Clarify distinction between JSON and Python objects (GH-13…
…4154)*gh-134150: Clarify distinction between JSON objects and Python objects in json module docs* Revert change to JSON introduction* Clarify occurrences of "object literal" as JSON(cherry picked from commitfa4e088)Co-authored-by: Micha Albert <micha@2231puppy.tech>
  • Loading branch information
@MichaByte@miss-islington
MichaByte authored andmiss-islington committedMay 18, 2025
commitdbe54e5d4913f3b4136154dbd89f3886aab5ff64
15 changes: 10 additions & 5 deletionsDoc/library/json.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,12 +18,17 @@ is a lightweight data interchange format inspired by
`JavaScript <https://en.wikipedia.org/wiki/JavaScript>`_ object literal syntax
(although it is not a strict subset of JavaScript [#rfc-errata]_ ).

.. note::
The term "object" in the context of JSON processing in Python can be
ambiguous. All values in Python are objects. In JSON, an object refers to
any data wrapped in curly braces, similar to a Python dictionary.

.. warning::
Be cautious when parsing JSON data from untrusted sources. A malicious
JSON string may cause the decoder to consume considerable CPU and memory
resources. Limiting the size of data to be parsed is recommended.

:mod:`json` exposes an API familiar to users of the standard library
This module exposes an API familiar to users of the standard library
:mod:`marshal` and :mod:`pickle` modules.

Encoding basic Python object hierarchies::
Expand DownExpand Up@@ -60,7 +65,7 @@ Pretty printing::
"6": 7
}

Specializing JSON object encoding::
Customizing JSON object encoding::

>>> import json
>>> def custom_json(obj):
Expand All@@ -83,7 +88,7 @@ Decoding JSON::
>>> json.load(io)
['streaming API']

Specializing JSON object decoding::
Customizing JSON object decoding::

>>> import json
>>> def as_complex(dct):
Expand DownExpand Up@@ -279,7 +284,7 @@ Basic Usage

:param object_hook:
If set, a function that is called with the result of
any object literal decoded (a :class:`dict`).
anyJSONobject literal decoded (a :class:`dict`).
The return value of this function will be used
instead of the :class:`dict`.
This feature can be used to implement custom decoders,
Expand All@@ -289,7 +294,7 @@ Basic Usage

:param object_pairs_hook:
If set, a function that is called with the result of
any object literal decoded with an ordered list of pairs.
anyJSONobject literal decoded with an ordered list of pairs.
The return value of this function will be used
instead of the :class:`dict`.
This feature can be used to implement custom decoders.
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp