35
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

jqコマンドでjsonを扱う

Posted at

json形式のデータを扱うことが出来るコマンド。

導入(Mac)

brewでインストールする。
homebrewを導入していない時は入れる。

$ brew install jq

#使い方
例えばlivedoor天気情報APIから

$ curl 'http://weather.livedoor.com/forecast/webservice/json/v1?city=130010' | jq

こんな風に叩くと

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7934    0  7934    0     0  45091      0 --:--:-- --:--:-- --:--:-- 45597
{
  "pinpointLocations": [
    {
      "link": "http://weather.livedoor.com/area/forecast/1310100",
      "name": "千代田区"
    },
    {
      "link": "http://weather.livedoor.com/area/forecast/1310200",
      "name": "中央区"
    },
    {
      "link": "http://weather.livedoor.com/area/forecast/1310300",
      "name": "港区"
    },
    {
      "link": "http://weather.livedoor.com/area/forecast/1310400",
      "name": "新宿区"
    },
    {
      "link": "http://weather.livedoor.com/area/forecast/1310500",
      "name": "文京区"
    },
.
・
・

という感じに表示出来る。

その他の使い方

35
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
35
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?