Closed gmccullo closed 3 years ago
When the quotes are stripped on using sort-json, that usually means your JSON is not itself strict JSON (as-in, not strict according to the internal JSON parser) - I've included two parser which means you can sort JavaScript JSON (aka without quotes and with comments etc...).
Can you post an example of the JSON you are trying to sort here?
Thanks.
I used it to sort my settings file. I would argue the extensions should not alter the keys regardless. Anyway here's a minimum repro:
BEFORE:
{
"editor.rulers": [
{
"color": "#eee",
"column": 20
},
],
"todo-tree.general.tags": [
"BUG:",
],
}
AFTER:
{
"editor.rulers": [
{
color: "#eee",
column: 20
}
],
"todo-tree.general.tags": [
"BUG:"
]
}
Hmm.. That does look wrong. Let me take a look. Thanks.
The problem is the trailing commas. Looks like that breaks the built-in JSON parser.
This works fine for me...
{ "editor.rulers": [ { "color": "eee", "column": 20 } ], "todo-tree.general.tags": [ "BUG:" ] }
FWIW, I do plan at some point to switch over to a different parser (that can handle things like this, and comments) - the babel parser seemed best last time I looked. But, I've not had time to do the work :-|.
New parser implemented.
Sorting strips quotes off property keys. That's an error.