Home

Awesome

Build Status

Jsoncat

jsoncat_logo

Description

Json pretty-print parser based on a recursive lexical analyser. The parser was based on the specification defined at json.org. The input file is parsed to build a json object. If the object is correct, it will be pretty-printed to standard output.

Check out the blog post about jsoncat [pt-BR]

Usage

Jsoncat parses a json that comes from a pipe to stdin. For example, parsing a request:

$> curl -s https://pantuza.com/sample.json --insecure | jsoncat
{
        'what': "A json example file",
        'test': true,
        'values': [ 42, 10, 5.32],
        'data': {
                'name': 'Test Name',
                'type': null
        }
}

Or simple by passing a path to a json file as follows:

$> jsoncat tests/samples/input_06.json
{
        'age': 42,
        'name': 'marvin',
        'what': 'robot'
}

Or yet, again from stdin, by echoing a json:

$> echo "{'test': true}" | jsoncat
{
        'test': true
}

Installation

From Homebrew for Mac OS

In a terminal install jsoncat from tap source:

$> brew tap pantuza/homebrew-jsoncat
$> brew install jsoncat
From source

Clone this repository, go to project directory and run:

$> make
$> make install

PS: I'm creating the RPM and DEB packages. A soon as possible you would install jsoncat from these sources.

Options

-v | --version

Prints jsoncat version

-h | --help

Prints help message

--no-color

Removes the color characters. This characters are useful only for the terminal that will pretty print the Json. If you want to store the resulted Json to a file, use this option to persist a valid Json.

--tab-stop

Sets the tab stop used by Jsoncat. We never insert tab character. Instead, we expand tab with spaces. For that, the --tab-stop configures the number of spaces used for Json indentation. The default value is 4.

Contributing

We are welcome to contributions. Just do a fork, modify some code and make a pull request. You may not forget to describe your modifications very well. It will help us on the code review. Try to write some tests, it would be nice.

Coding style

we are not stringent with it, but we like the GNU C coding style.

Testing

Our test scripts are testing only the binary execution and checking for some error during the parsing and at the result. We use bash scripts to do this task.

At the tests directory, there is a utils.sh file that defines the tests functions. Each other file in this directory uses the utils functions to run tests over strings, numbers, objects, arrays and constants. Also, there is a script to test the command line options. The samples directory has a lot of json sample files to use during development tests.

For now, we are not using any tool for testing :/. If you have suggestions for it, please put it in an issue, we will certain check it out.

Author

Written by Gustavo Pantuza

Reporting Bugs

Report Jsoncat bugs to gustavopantuza@gmail.com