Closed Whadup closed 4 years ago
Yes, that sound reasonable. The current code also ruins the formatting. How did you get around that? I did not find any extension that support jsonl files.
I wrote some code that does what you describe automatically:
\n
with ,
[
and ]
\n
I have some unit tests and also tested it on one file:
Currently I check for the file extension jsonl
. Is this enough? Anything else I need to be aware of? The code can handle empty lines. Not sure if that would be even valid jsonl, but it certainly doesn't hurt to keep it.
sounds perfect. Speaking of "valid", I'm not actually sure if .jsonl is a standardised format, or just something people came up with who need to write json arrays incrementally.
As for the formatting part, you might even keep the old formatting if you don't sort the array, but only its indices. Then you can use the sorted indices to construct the output from the original line strings, no JSON-serialization required.
Unfortunately it's not as easy when sorting real json files, as in your other github issue...
I have build a pre-release for the 2.0.0 version that contains jsonl support here. You can install it, if you go to extensions in vscode, click on the ...
on the top right and select Install from VSIX
. I would like to hear you feedback, before I officially release the new version.
This is now part of 2.0.0
Would be great if this supported .jsonl files, where each line is a valid json object.
As a workaround, I put a comma at the end of each line and surround the whole file with [,] but that's rather annoying.