A CLI for jsonc - json with comments
Provides conversion and validation capabilities for jsonc files. jsonc-cli can perform two operations right now.
- Takes jsonc files as input and outputs json file without comments
- Checks if provided jsonc file is a valid jsonc or not.
Requires git to clone and Go to build.
Clone and navigate to directory
$ git clone https://github.com/muhammadmuzzammil1998/jsonc-cli.git
$ cd jsonc-cli
Get dependencies and build
$ go get -d .
$ go build
Follow the guide on the releases page for detailed instructions.
Download .deb
file for jsonc-cli from the releases page.
$ wget https://github.com/muhammadmuzzammil1998/jsonc-cli/releases/download/{version}/jsonc-cli-linux-{amd64/386}.deb
Install using dpkg
$ sudo dpkg -i jsonc-cli-linux-{amd64/386}.deb
Start PowerShell as an admin
Download .exe
file for jsonc-cli from the releases page.
PS > Invoke-WebRequest https://github.com/muhammadmuzzammil1998/jsonc-cli/releases/download/{version}/jsonc-cli-windows-{amd64/386}.exe -OutFile jsonc-cli.exe
Move jsonc-cli.exe
to C:\Windows
or store it somewhere and add it to path.
PS > mv .\jsonc-cli.exe C:\Windows\jsonc-cli.exe
You can download the binary already built for your system or build it yourself. To install, see install from source
- Adapt
{version}
number. Check version number from here. - Choose your architecture,
amd64
for 64 bit and386
for 32 bit systems.
Clone and navigate to directory
$ git clone https://github.com/muhammadmuzzammil1998/jsonc-cli.git
$ cd jsonc-cli
Get dependencies and build
$ go get -d .
$ go install
$ go get -t -u muzzammil.xyz/jsonc-cli
$ jsonc-cli -version
🎉 jsonc-cli
🤖 Version: 1.0
🌐 Repository: https://github.com/muhammadmuzzammil1998/jsonc-cli
Flags | Description |
---|---|
-i | Path to the source file. |
-o | Path to the output file. |
-asis | Print the JSONC as-is. Can be piped. |
-p | Print the JSON converted data to screen. Can be piped. |
-v | Check if provided jsonc file using -i is valid or not |
-version | Prints version and other details |
-help | Prints help |
Converting a jsonc file to json
$ jsonc-cli -i data.jsonc
🤖 No destination provided. Using source filename ./data.json
✅ Coversion successful! JSON written to ./data.json
$ jsonc-cli -i data -o js
🤖 No destination provided. Using source filename ./data.json
✅ Coversion successful! JSON written to ./js.json
Printing converted JSON
$ jsonc-cli -i data.jsonc -p
[{"name":"Mohammad Muzammil Khan","ID":1543133742}]
Printing JSONC as-is
$ jsonc-cli -i data.jsonc -asis
[
{
"name": "Mohammad Muzammil Khan", // User name
"ID": 1543133742 // User ID
}
]
Validating JSONC
$ jsonc-cli -i data.jsonc -v
👍 Valid - the jsonc file .\data.jsonc is valid
* Adding extension is optional. However, it reducing ambiguity and chances of error.
Contributions are welcome but kindly follow the Code of Conduct and guidelines. Please don't make Pull Requests for typographical errors, grammatical mistakes, "sane way" of doing it, etc. Open an issue for it. Thanks!