/
json.1
187 lines (186 loc) · 3.94 KB
/
json.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
.\" Generated with Ronnjs/v0.1
.\" http://github.com/kapouer/ronnjs/
.
.TH "JSON" "1" "October 2011" "" ""
.
.SH "NAME"
\fBjson\fR \-\- JSON love for your command line
.
.SH "SYNOPSIS"
\fB<something generating JSON on stdout> | json [OPTIONS] [LOOKUPS]\fR
.
.SH "DESCRIPTION"
Pipe in your JSON for nicer (pretty\-printed) output or supply one or more
lookups\fB to extract a subset of the JSON\. HTTP header blocks are skipped by
default (as from \fRcurl \-i`) by default\.
.
.P
See more complete documentation in the readme and changelog:
.
.IP "\(bu" 4
README: \fIhttps://github\.com/trentm/json#readme\fR
.
.IP "\(bu" 4
Change log: \fIhttps://github\.com/trentm/json/blob/master/CHANGES\.md\fR
.
.IP "" 0
.
.SH "OPTIONS"
If your JSON output is a REST API response, it might include the headers
(e\.g\. when calling with \fBcurl \-i\fR)\. By default \fBjson\fR will pass those headers
through (without choking on them)\. However if you want then stripped you
can use:
.
.P
\fB\-H\fR
drop any HTTP header block (as from \fBcurl \-i \.\.\.\fR)
.
.P
By default \fBjson\fR outputs results in a "flat" format that is intended to be
of most use to the UNIX command\-line\. Currently the only difference between
flat and JSON output is that a simple string result is printed \fIwithout\fR JSON\'s
double\-quotes\. Other output formats are supported:
.
.P
\fB\-o, \-\-output MODE\fR
Specify an output mode\. One of:
.
.IP "" 4
.
.nf
jsony (default): JSON with string quotes elided
json: JSON output, 2\-space indent
json\-N: JSON output, N\-space indent, e\.g\. \'json\-4\'
inspect: node\.js `util\.inspect` output
.
.fi
.
.IP "" 0
.
.P
\fB\-i\fR
shortcut for \fB\-o inspect\fR
.
.P
\fB\-j\fR
shortcut for \fB\-o json\fR
.
.P
You can process elements of an input array separately and generate tabular
output:
.
.P
\fB\-a, \-\-array\fR
Process input as an array of separate inputs and output in tabular form\.
.
.P
\fB\-d DELIM\fR
Delimiter string for tabular output (default is \' \')\.
.
.P
Miscellaneous options:
.
.P
\fB\-h, \-\-help\fR
print this help info and exit
.
.P
\fB\-\-version\fR
print version of this command and exit
.
.P
\fB\-q, \-\-quiet\fR
don\'t warn if input isn\'t valid JSON
.
.SH "EXAMPLES"
A REST API:
.
.IP "" 4
.
.nf
$ curl \-s http://github\.com/api/v2/json/repos/show/joyent/node
{"repository":{"has_wiki":true,"forks":597,"language":"C++",\.\.\.}
.
.fi
.
.IP "" 0
.
.P
Nice output by default:
.
.IP "" 4
.
.nf
$ curl \-s http://github\.com/api/v2/json/repos/show/joyent/node | json
{
"repository": {
"has_wiki": true,
"language": "C++",
"homepage": "http://nodejs\.org/",
"open_issues": 271,
"fork": false,
"has_issues": true,
"url": "https://github\.com/joyent/node",
"forks": 597,
"created_at": "2009/05/27 09:29:46 \-0700",
"pushed_at": "2011/03/18 15:19:24 \-0700",
"size": 20984,
"private": false,
"has_downloads": false,
"name": "node",
"owner": "joyent",
"organization": "joyent",
"watchers": 5584,
"description": "evented I/O for v8 javascript"
}
}
.
.fi
.
.IP "" 0
.
.P
Say you just want to extract one value:
.
.IP "" 4
.
.nf
$ curl \-s https://github\.com/api/v2/json/repos/show/joyent/node \\
| json repository\.open_issues
271
.
.fi
.
.IP "" 0
.
.P
More examples at \fIhttps://github\.com/trentm/json#readme\fR\|\.
.
.SH "BUGS"
\fBjson\fR is written in JavaScript and requires node\.js (\fBnode\fR)\. Report bugs
to \fIhttps://github\.com/trentm/json/issues\fR\|\.
.
.SH "COPYRIGHT"
json is Copyright (c) 2011 Trent Mick
.
.SH "SEE ALSO"
.
.IP "\(bu" 4
json:select: \fIhttp://jsonselect\.org/\fR
.
.IP "\(bu" 4
jsonpipe: \fIhttps://github\.com/dvxhouse/jsonpipe\fR
.
.IP "\(bu" 4
json\-command: \fIhttps://github\.com/zpoley/json\-command\fR
.
.IP "\(bu" 4
JSONPath: \fIhttp://goessner\.net/articles/JsonPath/\fR, \fIhttp://code\.google\.com/p/jsonpath/wiki/Javascript\fR
.
.IP "\(bu" 4
jsawk: \fIhttps://github\.com/micha/jsawk\fR
.
.IP "\(bu" 4
jshon: \fIhttp://kmkeen\.com/jshon/\fR
.
.IP "" 0