Skip to content

gh-134150: Clarify distinction between JSON and Python objects #134154

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 18, 2025

Conversation

MichaByte
Copy link
Contributor

@MichaByte MichaByte commented May 17, 2025

This PR clears up the ambiguity between JSON objects and Python objects in the json module docs by adding a note to inform the reader of the distinction. I also changed two occurrences of the word "specializing" with the word "customizing", since the latter seems to be a better fit for describing what's happening. Let me know if I need to make any changes!

Micha


📚 Documentation preview 📚: https://cpython-previews--134154.org.readthedocs.build/en/134154/library/json.html

@python-cla-bot
Copy link

python-cla-bot bot commented May 17, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

Copy link
Contributor

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid changes not related to the issue, we generally try to keep pull requests focused to make them easier to review.

This does not fully resolve this issue, there are several places in the docs where it should be clarified e.g. "object" -> "JSON object"

Edit:

I apologize for my review, I was tired and very inconsiderate. Welcome to contributing to cpython, I hope this will be one of many prs:-)

(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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glossary link to Python object?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, I don't think a glossary link will help here. The reader in this case will know what a Python object is.

.. 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again unrelated, please revert and do not make a mess of this pr.

though it should be changed to

:mod:`!json`

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not make a mess of this pr.

@StanFromIreland Please be aware that this is a first-time contributor. Let's try to be more constructive by pointing to the devguide.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "This module" make a better sentence anyway.

@@ -60,7 +65,7 @@ Pretty printing::
"6": 7
}

Specializing JSON object encoding::
Customizing JSON object encoding::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I think this is a better word, and we don't want to make a separate PR for it, it would be too much churn.

@@ -83,7 +88,7 @@ Decoding JSON::
>>> json.load(io)
['streaming API']

Specializing JSON object decoding::
Customizing JSON object decoding::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

@ZeroIntensity ZeroIntensity added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels May 17, 2025
@MichaByte
Copy link
Contributor Author

CCing @nedbat, who helped me make these changes at PyCon

@nedbat nedbat merged commit fa4e088 into python:main May 18, 2025
28 checks passed
@miss-islington-app
Copy link

Thanks @MichaByte for the PR, and @nedbat for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs May 18, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 18, 2025
…ythonGH-134154)

* pythongh-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 commit fa4e088)

Co-authored-by: Micha Albert <micha@2231puppy.tech>
@bedevere-app
Copy link

bedevere-app bot commented May 18, 2025

GH-134166 is a backport of this pull request to the 3.14 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 18, 2025
…ythonGH-134154)

* pythongh-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 commit fa4e088)

Co-authored-by: Micha Albert <micha@2231puppy.tech>
@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label May 18, 2025
@bedevere-app
Copy link

bedevere-app bot commented May 18, 2025

GH-134167 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label May 18, 2025
nedbat pushed a commit that referenced this pull request May 18, 2025
…GH-134154) (#134167)

gh-134150: Clarify distinction between JSON and Python objects (GH-134154)

* 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 commit fa4e088)

Co-authored-by: Micha Albert <micha@2231puppy.tech>
nedbat pushed a commit that referenced this pull request May 18, 2025
…GH-134154) (#134166)

gh-134150: Clarify distinction between JSON and Python objects (GH-134154)

* 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 commit fa4e088)

Co-authored-by: Micha Albert <micha@2231puppy.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants