Show HN: A command-line utility-belt for hacking JSON and Javascript
github.com
github.com
Challenge accepted.
cat earthporn.json | \
jshon -e data -e children -a -e data -e title -u | \
sed -r 's/\<./\U&/g' | tr -d ' ' | sed 's/[^a-zA-Z].*//g`
I'll stick with Jshon for my routers and other little ARM devices.But this utility is pretty nifty. Personally the whole select thing feels a little too magic for my taste, but when it works it looks quite compact. I'll probably be borrowing that colorizing feature tomorrow. And thanks for the link at the bottom :-)
sed -r 's/\<./\U&/g; s/ +//g; s/[^a-zA-Z].*//'
would be better. Note, the last s/// doesn't need a g.But... "structured data", at least in his examples (and nearly all the JSON I see on the web), is... text. Does his perl script handle binary json?
The author says: "Try doing THAT with any other CLI one-liner!"
Indeed I will, since I do not know perl. Should I learn it?
The folllowing seems to work, but I only tested it on the author's earthporn.json example
1. compile CamelCase filter called yycamel
2. compose throwaway sed oneliner to massage the text
3. pipe through unicode to ascii filter (not included)
4. pipe through yycamel
(I really do not like CamelCase, but whatever.)
cat > camel.l << eof
%%
[ ][A-Za-z] printf("%c",toupper(yytext[1]));
eof
flex -iCfa camel.l
cc lex.yy.c -static -ll -o yycamel
sed 's/\"title\": /\
/g;' earthporn.json |sed 's/[[(]/\
/g;' | sed '/^\"[a-zA-Z]/!d;s/[^a-zA-Z]/ /g;s/ */ /g' |yycamelcat data.json | underscore print --color
Gives you a well-formatted, color coded output for your JSON data. That is just one of the many things it can do.
command_that_emits_json | clijson
:)
Everything but the color.
Seeing as lots of systems have yajl.
something-generating-JSON-on-stdout | json [OPTIONS] [LOOKUPS]
[1] http://trentm.com/json/ cat hoge.json | json | less