Skip to content

Instantly share code, notes, and snippets.

@daxanya2
Created February 8, 2014 15:21
Show Gist options
  • Save daxanya2/8885328 to your computer and use it in GitHub Desktop.
Save daxanya2/8885328 to your computer and use it in GitHub Desktop.
jqのバージョンを最新にしたらjsonの処理が捗りすぎて怖い ref: http://qiita.com/daxanya1/items/6ed6b292a838ed750d35
{"messages":[{"date":"2014-02-06T10:01:07+0900","from":{"name":"daxanya (-v-)","user_id":544xxx},"message":"https:\/\/github.com\/bowery\/orcheTstrate.js"},{"date":"2014-02-06T10:01:11+0900","from":{"name":"daxanya (-v-)","user_id":544xxx},"message":"orchestrate.js"},{"date":"2014-02-06T10:01:18+0900","from":{"name":"daxanya (-v-)","user_id":544xxx},"message":"http:\/\/www.slideshare.net\/who_you_me\/neo4j-24294061"},{"date":"2014-02-06T10:01:22+0900","from":{"name":"daxanya (-v-)","user_id":544xxx},"message":"\u30b0\u30e9\u30d5\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u300cNeo4j\u300d\u306e \u5c0e\u5165\u306e\u5c0e\u5165"}]}
$ git clone https://github.com/stedolan/jq.git
$ cd jq
$ autoreconf -i
$ ./configure
$ make
$ brew install automake
$ brew install bison
$ cd /usr/local/bin
$ ln -s ../Cellar/bison/3.0.2/bin/bison bison
$ ln -s ../Cellar/bison/3.0.2/bin/yacc yacc
$ cat example.json | jq '.messages[] | .date+" "+.message'
"2014-02-06T10:01:07+0900 https://github.com/bowery/orcheTstrate.js"
"2014-02-06T10:01:11+0900 orchestrate.js"
"2014-02-06T10:01:18+0900 http://www.slideshare.net/who_you_me/neo4j-24294061"
"2014-02-06T10:01:22+0900 グラフデータベース「Neo4j」の 導入の導入"
$ cat example.json | jq 'def a(f): f|split("T")|.[1]|split("+")|.[0]; .messages[] | a(.date)+" "+.message'
"10:01:07 https://github.com/bowery/orcheTstrate.js"
"10:01:11 orchestrate.js"
"10:01:18 http://www.slideshare.net/who_you_me/neo4j-24294061"
"10:01:22 グラフデータベース「Neo4j」の 導入の導入"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment