如何快速在Mac 安装 jq 命令行 JSON 解析器

jq 是什么

https://blog.csdn.net/shenhonglei1234/article/details/108045923

安装

brew install jq

过程如下

➜  ~ brew install jq
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/services).
==> New Formulae
aida-header           cloudflare-wrangler   efm-langserver        h2spec                kubevela              lp_solve              ocaml-zarith          tctl                  wayland-protocols
aliddns               coin3d                evernote2md           hblock                libbsd                lua@5.3               openalpr              tendermint            xcb-util-cursor
ansible@2.9           counterfeiter         f3d                   heppdt2               libcap-ng             luajit-openresty      osmcoastline          terracognita          xcb-util-image
atkmm@2.28            cpplint               flow-cli              hexo                  libmd                 luv                   parliament            terraform@0.13        xcb-util-keysyms
attr                  crane                 forge                 htmltest              libnsl                magic_enum            pdftilecut            tgenv                 xcb-util-renderutil
aws-console           crcany                gallery-dl            indicators            libpinyin             massdns               php@7.4               thrax                 xcb-util-wm
aws-rotate-key        curlie                gdu                   inframap              libprelude            md4c                  pkger                 tm                    xcbeautify
bandit                dasel                 giza                  jpeg-xl               librttopo             mermaid-cli           ptpython              trec_eval             xcinfo
bpython               datalad               gofumpt               jql                   libtirpc              mockery               richmd                truffle               xcprojectlint
bpytop                dnsx                  gojq                  json5                 libva                 mpdecimal             rtl_433               utf8cpp               xinput
cairomm@1.14          docui                 gopls                 kcgi                  libvdpau              msc-generator         rttr                  v2ray                 ykdl
cargo-audit           dprint                goredo                keptn                 libvnc                muffet                ruby@2.7              vc                    youtube-dlc
cargo-watch           driftctl              grokj2k               khiva                 libxml++@4            name-that-hash        spack                 vitess                youtubedr
cherrytree            dstask                grokmirror            ko                    libxml++@5            nuclei                sqlc                  vsh                   yq@3
clash                 duf                   gtkmm4                kubecm                logswan               oakc                  t-rec                 wayland               zsh-async
==> Updated Formulae
Updated 4999 formulae.
==> Renamed Formulae
glibmm@2.64 -> glibmm@2.66       gtk+4 -> gtk4                    ht-rust -> xh                    now-cli -> vercel-cli            pangomm@2.42 -> pangomm@2.46     prest -> prestd
==> Deleted Formulae
curl-openssl          dtrx                  gobby                 godep                 rmtrash               stlviewer             unp64                 unrar                 xspin
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

==> Downloading https://homebrew.bintray.com/bottles/oniguruma-6.9.6.big_sur.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/505599ad17e21360a58a89db2133115b5aa109cdebd5d284bec2bc25cfee5062?response-content-disposition=attachment%3Bfilename%3D%22oniguruma-6.9.6.bi
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/jq-1.6.big_sur.bottle.1.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/bf0f8577632af7b878b6425476f5b1ab9c3bf66d65affb0c455048a173a0b6bf?response-content-disposition=attachment%3Bfilename%3D%22jq-1.6.big_sur.bot
######################################################################## 100.0%
==> Installing dependencies for jq: oniguruma
==> Installing jq dependency: oniguruma
==> Pouring oniguruma-6.9.6.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/oniguruma/6.9.6: 16 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
➜  ~

验证

➜  ~ echo '{"foo": 0}' | jq .
{
  "foo": 0
}
➜  ~ export CURRENT_VERSION=4.2.25
export CHANNEL_NAME=stable-4.3
curl -sH 'Accept:application/json' "https://api.openshift.com/api/upgrades_info/v1/graph?channel=${CHANNEL_NAME}" | jq -r --arg CURRENT_VERSION "${CURRENT_VERSION}" '. as $graph | $graph.nodes | map(.version=='\"$CURRENT_VERSION\"') | index(true) as $orig | $graph.edges | map(select(.[0] == $orig)[1]) | map($graph.nodes[.].version) | sort_by(.)'
[
  "4.2.26",
  "4.2.27",
  "4.2.28",
  "4.2.29",
  "4.2.33",
  "4.2.34",
  "4.2.36",
  "4.3.18",
  "4.3.28",
  "4.3.35"
]
GitHub 加速计划 / js / json
41.72 K
6.61 K
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:1 个月前 )
960b763e 4 个月前
8c391e04 6 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐