Skip to content

mash/uncomment

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Uncomment

Uncomment is a simple command line tool to strip the comments out of relaxed JSON and output JSON as defined in RFC 7159, or in other words a JSON5 to JSON converter.

Usage

% cat infile.json
{
  // single line comments
  /*
   * or multi line comments
   */
  foo: "bar",
}

% cat infile.json | bin/uncomment
{"foo":"bar"}

% bin/uncomment infile.json
{"foo":"bar"}

% bin/uncomment -i infile.json -o outfile.json
outfile.json

% bin/uncomment -h
Usage of bin/uncomment:
  -i string
        Input file name
  -n    Do not print the trailing newline character.
  -o string
        Output file name

Useful tricks

# jq expects strict JSON
% cat relaxed.json | uncomment | jq .

# if another tool expects a strict JSON file
% command -c `uncomment -i relaxed.json -o strict.json`

Install

% go get github.com/mash/uncomment/cmd/uncomment

See also

https://json5.org/

About

Uncomment is a tool to strip the comments out of a JSON file and output JSON

Resources

License

Stars

Watchers

Forks

Packages

No packages published