https://github.com/slice/json
A tiny Node.js CLI script to access JSON from stdin.
https://github.com/slice/json
json json-cli
Last synced: 11 months ago
JSON representation
A tiny Node.js CLI script to access JSON from stdin.
- Host: GitHub
- URL: https://github.com/slice/json
- Owner: slice
- Created: 2018-07-12T17:39:38.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-12T18:41:27.000Z (over 7 years ago)
- Last Synced: 2025-01-21T16:24:01.230Z (about 1 year ago)
- Topics: json, json-cli
- Language: JavaScript
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# json
a tiny utility for working with json from stdin
## installation
requires node 8+.
```sh
$ npm i -g @slicey/json
```
## usage
output is prettified for complex structures, and is not shortened. it is also
colored if stdout is a tty :)
```sh
# access from stdin:
$ curl -s https://httpbin.org/headers | json headers.User-Agent
'curl/7.54.0'
$ cat file.json | json mystery.fortune
'👀'
# arrays work:
$ echo '[1, 2, 3]' | json 0
1
# and so do objects:
$ echo '{ "hello there": "warm goodness" }' | json 'hello there'
'warm goodness'
# get you a shibe:
$ curl -s shibe.online/api/shibes | json 0 | xargs open # macOS
$ curl -s shibe.online/api/shibes | json 0 | xargs xdg-open # Linux
# direct file access? no prob:
$ json package.json bin.json
'bin/json'
$ json file.json subobject.another_subobject.subarray.2
'wow this is inside of an array'
# pretty printing too!
$ json package.json
{
name: '@slicey/json',
description: 'Quickly access JSON from stdin.',
...
# works with stdin also:
$ cat mysteries.json | json
[
{
created_at: '2009-01-05',
text: 'Where\'s my Cup Noodles?'
},
{
created_at: '2009-01-06',
text: 'My Cup Noodles have arms?'
}
...
```
## motivation
bored on a thursday