Skip to content

Keys in JSONObject are not maintaining their insertion order #920

@coding-er

Description

@coding-er

Hi,

I've encountered an issue with org.json.JSONObject where the order of key-value pairs is not preserved when constructing JSON objects. This is problematic for my use case, as the frontend relies on the specific order of the data.

After examining the source code, I noticed that org.json.JSONObject uses HashMap internally, which does not maintain the insertion order of keys. I have two main questions regarding this issue:

Preservation of Insertion Order: Are there any strategies or plans to ensure the insertion order of key-value pairs in org.json.JSONObject?

Design Philosophy: What was the rationale behind using HashMap for org.json.JSONObject, given that it doesn't preserve order? Is there an intention to support ordered JSON in future versions of the library?

Thank you for your attention to this matter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions