-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
91 lines (69 loc) · 2.28 KB
/
README
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
jtools - simple command-line utilities for working with JSON.
INSTALLATION
Install Makamaka Hannyaharamitu's JSON module from CPAN:
$ cpan JSON
Copy jd and jf to somewhere in your PATH:
$ cp jd jf ~/bin
That's it.
USAGE
Both jd and jf behave like standard Unix filters: they take text on standard
input (or from files specified on the command-line), operate on it, and dump
the result to standard output.
jd simply pretty-prints its output:
$ echo '{"nemeses":{"batman":"joker", "harry":"voldemort"}}' | jd
{
"nemeses" : {
"batman" : "joker",
"harry" : "voldemort"
}
}
jf accepts a series of XPath-like field specifications, and returns only those
parts of its input, preserving as much structure as necessary. With the -p
option it will pretty-print its output.
$ curl -s -upozorvlak:<my password here> http://api.twitter.com/1/statuses/mentions.json | jf -p user/name user/screen_name text
[
{
"text" : "@pozorvlak I have to admit that if you have polymorphism then things like +. are particularly pointless.",
"user" : {
"name" : "Christopher Yocum",
"screen_name" : "cyocum"
}
},
{
"text" : "@pozorvlak Huh, I still like the safety that static typing gives you.",
"user" : {
"name" : "Christopher Yocum",
"screen_name" : "cyocum"
}
}
... etc ...
]
Or from a file:
jf -p user/name user/screen_name text -- one_I_prepared_earlier
[
{
"text" : "@pozorvlak I have to admit that if you have polymorphism then things like +. are particularly pointless.",
"user" : {
"name" : "Christopher Yocum",
"screen_name" : "cyocum"
}
},
{
"text" : "@pozorvlak Huh, I still like the safety that static typing gives you.",
"user" : {
"name" : "Christopher Yocum",
"screen_name" : "cyocum"
}
}
... etc ...
]
COPYRIGHT AND LICENSE
Copyright 2010 by Miles Gould.
These programs are free software; you can redistribute and/or modify them under
the same terms as Perl itself.
CONTRIBUTING
Please send bug reports and/or patches to [email protected]. Or better yet,
fork the project on GitHub! The URL's http://github.com/pozorvlak/jtools.
UPDATES
Any new versions will be announced on my blog:
http://pozorvlak.livejournal.com/tag/jtools.