LoginSignup
1
2

More than 5 years have passed since last update.

curlコマンドの出力をjqで整理して表示する

Last updated at Posted at 2017-06-28

curlコマンド

$ curl -s https://randomuser.me/api | jq '.'
{
  "results": [
    {
      "gender": "male",
      "name": {
        "title": "mr",
        "first": "dominic",
        "last": "gauthier"
      },
      "location": {
        "street": "6629 tecumseh rd",
        "city": "melbourne",
        "state": "yukon",
        "postcode": 82683
      },
      "email": "dominic.gauthier@example.com",
      "login": {
        "username": "bigkoala670",
        "password": "nasty",
        "salt": "3BIaho9m",
        "md5": "32e1eafd2e3333279d08ba937b7754f7",
        "sha1": "63a68d471159981a9482fbe50cb2c776f6b36743",
        "sha256": "642181246f52f0269fb005bde6ef844d683e86f1c39605273ee1dc1d8429ca07"
      },
      "dob": "1955-12-25 09:38:26",
      "registered": "2015-06-12 04:49:56",
      "phone": "024-571-2877",
      "cell": "461-200-6741",
      "id": {
        "name": "",
        "value": null
      },
      "picture": {
        "large": "https://randomuser.me/api/portraits/men/42.jpg",
        "medium": "https://randomuser.me/api/portraits/med/men/42.jpg",
        "thumbnail": "https://randomuser.me/api/portraits/thumb/men/42.jpg"
      },
      "nat": "CA"
    }
  ],
  "info": {
    "seed": "c36fa7af7c25f85c",
    "results": 1,
    "page": 1,
    "version": "1.1"
  }
}

場所指定

.の後ろに文字指定する

$ curl -s https://randomuser.me/api | jq '.info.page'
# 1

$ curl -s https://randomuser.me/api | jq '.info.seed'
# "65a0130f9f6548f6"
1
2
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
1
2