richie5um / vscode-sort-json

VSCode Extension to Sort JSON objects
https://marketplace.visualstudio.com/items?itemName=richie5um2.vscode-sort-json
MIT License
110 stars 19 forks source link

Feature Request: Sort String arrays #24

Closed HaaLeo closed 5 years ago

HaaLeo commented 5 years ago

Description

The extension should be capable to sort simple "string-only" arrays as well.

Example

Input

{
    "MyArray": [
        "b",
        "c",
        "a"
    ],
    "Ahoi": true
}

Expected Output

{
    "Ahoi": true,
    "MyArray": [
        "a",
        "b",
        "c"
    ]
}
tillig commented 5 years ago

Technically this would be a breaking change to the JSON since array order in many cases is important, though if it's off by default it'd be fine.

richie5um commented 5 years ago

I think you'd be better selecting the specific array elements and using VS's built in 'Sort lines' command. Trying to add this to SortJSON in a way that made sense and didn't break array order (for those that want to preserve their JSON) seems complex.