← 返回首页
JSON does not preserve the order of OrderedDict · Issue #100272 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

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

Provide feedback

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

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

JSON does not preserve the order of OrderedDict #100272

New issue
New issue

Description

#95385 caused a regression in JSON serialization of OrderedDict when use the C implementation.

>>> import collections, json >>> od = collections.OrderedDict(a=1, b=2) >>> od.move_to_end('a') >>> od OrderedDict([('b', 2), ('a', 1)]) >>> json.dumps(od) '{"a": 1, "b": 2}'

With the pure Python implementation, as well as in older Pythons, you get '{"b": 2, "a": 1}'.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixestype-bugAn unexpected behavior, bug, or error

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    • Open in GitHub Copilot app

    Footer

    © 2026 GitHub, Inc.