Skip to content

mjurczyk/json-viewer

Repository files navigation

JSON Viewer

Pretty JSON viewer for your terminal

jsonviewer2


🚀 master ▶︎ npm version CircleCI codecov

🛠 develop ▶︎ GitHub version CircleCI codecov maintainer

📚 dependencies ▶︎ dependencies Status devDependencies Status

👀 code climate ▶︎ Code Climate Issue Count


After only so many times I was trying to recall a script or a dependency from the package.json, having my IDE closed and terminal opened.

Preview your JSON files, like package.json or database logs, in a readable form, and reach inside the structure of your file to fetch only the data that you really care to see.

Installation

You will need any recent node environment installed on your machine. To install json-viewer use npm preinstalled with node:

npm install -g json-viewer

This will install the node package, as well as the json terminal utility.

Usage

Using the viewer is as simple as using cat:

json package.json dependencies.gulp

Will output the dependencies.gulp parameter value from the package.json structure.

If you you would like to have the output properly colored, for readability, you can use either the -c flag, or set it permanently by using --always-color once.

json --always-color
json package.json scripts.compile
json myJsonFile.json user.friends._ids

If the parameter you ask for doesn't exist, viewer will return the last valid parent and inform you about the problem.

Autocompletion

You can use the tab key to browse the JSON properties on the fly and autofill long names. In order to enable this feature, you should append the autocompletion function to your .bashrc, .bash_profile, .zshrc. You can do using the build-in flag:

json --completion >> ~/.bash_profile

Testing

Testing module provides some basic coverage for the functionality:

npm run test

In order to test the CLI features and the auto-completion, use:

npm run test:live

This will build the scripts, pack them, install as a CLI and update the autocompletion script. You should also add the following lines to your .bashrc:

if [ -f ~/.json-autocomplete ]; then
  . ~/.json-autocomplete
fi

License

MIT :octocat:

About

Pretty JSON viewer for the terminal

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •