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.
You will need any recent node environment installed on your machine. To install json-viewer use npm preinstalled with node:
npm install -g json-viewerThis will install the node package, as well as the json terminal utility.
Using the viewer is as simple as using cat:
json package.json dependencies.gulpWill 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._idsIf the parameter you ask for doesn't exist, viewer will return the last valid parent and inform you about the problem.
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_profileTesting module provides some basic coverage for the functionality:
npm run testIn order to test the CLI features and the auto-completion, use:
npm run test:liveThis 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
fiMIT ![]()
