Sorting JSON when keys are the same
Is your feature request related to a problem? Please describe. We use the sortJson option to make sure our directus config works well in version control: the diffs only show what actually changes, not things being reordered. However we noticed that this option only sorts the keys. This makes sense, but we have encountered a scenario where several items have exactly the same keys. In particular we have in operations.json several items with these keys:
{
"_syncId": "...",
"flow": "...",
"key": "event",
"name": "Event",
"options": {
"collection": "events",
"key": [
"{{$trigger.payload.event}}"
]
},
"position_x": 1,
"position_y": 1,
"reject": null,
"resolve": "...",
"type": "item-read"
},
Describe the solution you'd like It would be nice if items with exactly the same keys would then be sorted by some value (perhaps the ID ?) so that when using sortJson, we can truly expect no random reordering on a save
Describe alternatives you've considered We're considering adding a hook for this on our end, but this would make sense in the spirit of the sortJson option, since its main purpose is working better with version control
Hi @SidonieBouthors I don't understand. How can an object have the same key twice?
I meant different objects having the same JSON keys, not the same object keys. When this occurs these object don't seem to always be sorted in the same order
Can you show me an example ?