Issue 19390 - Add "sorted" to JSONOptions
Summary: Add "sorted" to JSONOptions
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-10 11:52 UTC by Andre
Modified: 2024-12-01 16:34 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andre 2018-11-10 11:52:51 UTC
While calling std.json: toPrettyString I want to have an option to get the keys sorted. An option "sorted" could be added to JSONOptions.

Use case: I automatic create and update a JSON file. A user also updates this file manually. To have a stable order of the keys, the keys should always be stored in a sorted way.
This is good for the user and also for git diffs.
Comment 1 Vladimir Panteleev 2024-10-21 11:13:00 UTC
std.json has started to unconditionally sort the keys of JSON objects in its output a while ago. (It's an improvement over letting the order be dictated by the implementation details of the D associative array implementation in Druntime).
Comment 2 dlangBugzillaToGithub 2024-12-01 16:34:31 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/10360

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB