Skip to content

PEP 837: Extensible JSON serialization - #5031

Merged
serhiy-storchaka merged 11 commits into
python:mainfrom
serhiy-storchaka:pep-837-extensible-json
Jul 18, 2026
Merged

PEP 837: Extensible JSON serialization#5031
serhiy-storchaka merged 11 commits into
python:mainfrom
serhiy-storchaka:pep-837-extensible-json

Conversation

@serhiy-storchaka

@serhiy-storchakaserhiy-storchaka commented Jul 12, 2026

Copy link
Copy Markdown
Member

New PEP proposing an extension mechanism for the json encoder at
three levels: the __json__()/__raw_json__() protocol (library
level), a copyreg.json() registry following the copyreg.pickle()
precedent (application level), and a per-encoder dispatch_table
attribute mirroring pickle.Pickler (call level).

Reference implementation: python/cpython branch json-customize4
(link: https://github.com/serhiy-storchaka/cpython/tree/json-customize4).

The idea has been discussed repeatedly since 2010; see the PEP's
Motivation for the tracker issues and the python-ideas /
discuss.python.org threads:
2010,
2019,
2020,
2022 (registry),
2022–2024 (__json__).

Basic requirements (all PEP Types)

  • Read and followed PEP 1 & PEP 12
  • File created from the latest PEP template
  • PEP has next available number, & set in filename (pep-NNNN.rst), PR title (PEP 123: <Title of PEP>) and PEP header
  • Title clearly, accurately and concisely describes the content in 79 characters or less
  • Core dev/PEP editor listed as Author or Sponsor, and formally confirmed their approval
  • Author, Status (Draft), Type and Created headers filled out correctly
  • PEP-Delegate, Topic, Requires and Replaces headers completed if appropriate (none applicable)
  • Required sections included
    • Abstract (first section)
    • Copyright (last section; exact wording from template required)
  • Code is well-formatted (PEP 7/PEP 8) and is in code blocks, with the right lexer names if non-Python
  • PEP builds with no warnings, pre-commit checks pass and content displays as intended in the rendered HTML
  • Authors/sponsor added to .github/CODEOWNERS for the PEP

Standards Track requirements

  • PEP topic discussed in a suitable venue with general agreement that a PEP is appropriate
  • Suggested sections included (unless not applicable)
    • Motivation
    • Specification
    • Rationale
    • Backwards Compatibility
    • Security Implications
    • How to Teach This
    • Reference Implementation
    • Rejected Ideas
    • Open Issues

🤖 Generated with Claude Code

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@read-the-docs-community

read-the-docs-communityBot commented Jul 12, 2026

Copy link
Copy Markdown

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@serhiy-storchaka

Copy link
Copy Markdown
MemberAuthor

Discussion thread: https://discuss.python.org/t/pep-837-extensible-json-serialization/108124 (Discussions-To and Post-History headers added).

@hugovkhugovk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I probably won't have time for a full review due to EuroPython, here's a couple of suggestions.

Comment threadpeps/pep-0837.rst Outdated
Comment threadpeps/pep-0837.rst Outdated
Comment threadpeps/pep-0837.rst Outdated
Comment threadpeps/pep-0837.rst Outdated
serhiy-storchakaand others added 2 commits July 12, 2026 12:47
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Also fix the markup of the '__raw_json__ as a pure marker' bullet
(inline markup cannot be nested) and escape numpy.bool_ in the
appendix.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@serhiy-storchaka

Copy link
Copy Markdown
MemberAuthor

Thank you. Fixed rendering and modernized cpython-issue references.

serhiy-storchakaand others added 2 commits July 16, 2026 22:10
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@serhiy-storchakaserhiy-storchaka changed the title PEP 837: Extensible JSON serializationPEP 841: Extensible JSON serializationJul 16, 2026
PEP 837 was freed for this PEP's earlier claim when the conflicting
PEP was renumbered to 840 in python#5043.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@serhiy-storchakaserhiy-storchaka changed the title PEP 841: Extensible JSON serializationPEP 837: Extensible JSON serializationJul 16, 2026
serhiy-storchakaand others added 2 commits July 16, 2026 22:28

@hugovkhugovk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved with date change, thanks! :)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) July 18, 2026 11:50
@serhiy-storchaka
serhiy-storchaka merged commit c5f3f18 into python:mainJul 18, 2026
4 of 5 checks passed
@serhiy-storchaka
serhiy-storchaka deleted the pep-837-extensible-json branch July 18, 2026 11:51
@serhiy-storchaka

Copy link
Copy Markdown
MemberAuthor

Thank you for review.

@brianschubertbrianschubert added the new-pep A new draft PEP submitted for initial review label Aug 6, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-pepA new draft PEP submitted for initial review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@serhiy-storchaka@hugovk@brianschubert