LoginSignup
5
2

More than 1 year has passed since last update.

jqコマンドをインストール

Last updated at Posted at 2021-04-13

jqというjsonを扱うのに便利そうなものを知ったので早速!

Windowsにexeファイルでインストールする

  • 環境 : Windows10 Pro バージョン1909

「インストール」というより置くだけでOK!

  1. https://stedolan.github.io/jq/ の[Download jq]ボタンで「Windows」を選択してjq-win64.exeをダウンロードする
    • image.png
  2. jq-win64.exeを任意の場所に配置する
  3. エイリアスを登録する OR PATHを通す
# 任意の場所にjq用のディレクトリを作成する(しなくてもいい)
$ mkdir /c/apps/jq
# ダウンロードしたexeをjq用のディレクトリに配置する
$ mv /c/Users/ponsuke/Downloads/jq-win64.exe /c/apps/jq/
# バージョン確認して動くのを確認する
$ /c/apps/jq/jq-win64.exe -V
jq-1.6

# jqでエイリアスを設定する(PATHを通してもいいと思う)
$ echo "alias jq='/c/apps/jq/jq-win64.exe'" >> ~/.bashrc
# 反映する
$ source ~/.bash_profile 

# バージョン確認して動くのを確認する
$ jq -V
jq-1.6

MacにHomebrewでインストールする

  • 環境 : macOS Big Sur バージョン11.3.1
# 1. 使う前にアップデートする
$ brew update

# 2. お医者さんで健康なのを確認する
$ brew doctor
Your system is ready to brew.

# 3. jqコマンドをインストールする
$ brew install jq
==> Downloading https://ghcr.io/v2/homebrew/core/oniguruma/manifests/6.9.7.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/oniguruma/blobs/sha256:8154799c44b09d3283fab1d9e5c2a59c8026f8bf6358f94f99343cb0a9d84847
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:8154799c44b09d3283fab1d9e5c2a59c8026f8bf6358f94f99343cb0a9d84847?se=2021-06-21T14
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/jq/manifests/1.6-1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/jq/blobs/sha256:bf0f8577632af7b878b6425476f5b1ab9c3bf66d65affb0c455048a173a0b6bf
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:bf0f8577632af7b878b6425476f5b1ab9c3bf66d65affb0c455048a173a0b6bf?se=2021-06-21T14
######################################################################## 100.0%
==> Installing dependencies for jq: oniguruma
==> Installing jq dependency: oniguruma
==> Pouring oniguruma--6.9.7.1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/oniguruma/6.9.7.1: 14 files, 1.4MB
==> Installing jq
==> Pouring jq--1.6.big_sur.bottle.1.tar.gz
🍺  /usr/local/Cellar/jq/1.6: 18 files, 1.1MB
==> `brew cleanup` has not been run in 30 days, running now...
Removing: /Users/ponsuke/Library/Caches/Homebrew/git--2.31.1... (15MB)
Removing: /Users/ponsuke/Library/Caches/Homebrew/nkf--2.1.5.big_sur.bottle.tar.gz... (167KB)
Removing: /usr/local/Cellar/openjdk/15.0.2... (614 files, 324.9MB)
Removing: /Users/ponsuke/Library/Caches/Homebrew/openjdk--15.0.2... (190.9MB)
Removing: /Users/ponsuke/Library/Caches/Homebrew/pcre2--10.36... (2.0MB)
Removing: /Users/ponsuke/Library/Caches/Homebrew/tomcat--10.0.6.tar.gz... (11.3MB)
Removing: /Users/ponsuke/Library/Caches/Homebrew/tomcat@8--8.5.66.tar.gz... (10MB)
Removing: /Users/ponsuke/Library/Logs/Homebrew/tomcat... (102B)
Removing: /Users/ponsuke/Library/Logs/Homebrew/openjdk@11... (64B)
Removing: /Users/ponsuke/Library/Logs/Homebrew/openjdk... (64B)
Removing: /Users/ponsuke/Library/Logs/Homebrew/pcre2... (64B)
Removing: /Users/ponsuke/Library/Logs/Homebrew/openjdk@8... (64B)
Removing: /Users/ponsuke/Library/Logs/Homebrew/git... (64B)

# 4. インストールできたかバージョン確認で確かめる
$ jq --version
jq-1.6

# 5. Kintone REST API呼び出しで試してみる
$ curl -X GET -H 'X-Cybozu-Authorization:hogehoge==;Content-Type:application/json;charset=utf-8' https://{サブドメイン名}.cybozu.com/k/v1/records.json?app=11 | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4063    0  4063    0     0  31496      0 --:--:-- --:--:-- --:--:-- 31496
{
  "records": [
    {
      "レコード番号": {
        "type": "RECORD_NUMBER",
        "value": "3"
      },
      "更新者": {
        "type": "MODIFIER",
        "value": {
          "code": "ponsuke@example.com",
          "name": "ぽんすけ"
        }
      },
      "作成者": {
        "type": "CREATOR",
        "value": {
          "code": "ponsuke@example.com",
          "name": "ぽんすけ"
        }
      },
      "文字列__1行_": {
        "type": "SINGLE_LINE_TEXT",
        "value": "3000"
      },
#...省略...

使い方を紹介しているサイト

5
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
5
2