jsoncomma
is a simple utility which manages the commas in your JSON-like files. It adds needed ones, and removes the others.
You'll need to download the plugin for you favorite editor.
You will first need to install jsoncomma
, the program which fixes whatever JSON-like payload you give it.
You can download the standalone binary for your platform from the release page on GitHub. This is normally done automatically by your editor's plugin.
$ go get github.com/jsoncomma/jsoncomma
I struggle to see a common use case for using jsoncomma
from the terminal like this. Hence, it is not nearly as optimized as the web server which editors plugins use. It's still really fast, but in terms of memory usage, it won't perform as well as the web server.
$ cat > myfile.json
{
// my json file
"setting": "value"
"sneaky": "yep, that works [\"just\" fine, ]"
// it's good
"still though": "?", // trailing commas
}
$ jsoncomma myfile.json
$ cat myfile.json
{
// my json file
"setting": "value",
"sneaky": "yep, that works [\"just\" fine, ]",
// it's good
"still though": "?"
}
$ echo '{"some json": "to" "fix": [1 2 3,]}' | jsoncomma
{"some json": "to", "fix": [1, 2, 3]}
Happy not worrying about commas anymore!