Bug 19390 – Add "sorted" to JSONOptions

Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-11-10T11:52:51Z
Last change time
2024-12-01T16:34:31Z
Assigned to
No Owner
Creator
Andre
Moved to GitHub: phobos#10360 →

Comments

Comment #0 by andre — 2018-11-10T11:52:51Z
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 by dlang-bugzilla — 2024-10-21T11:13:00Z
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 by robert.schadek — 2024-12-01T16:34:31Z
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