How to install JQ on Mac by command-line?

前端 未结 5 643
长发绾君心
长发绾君心 2021-01-31 13:09

I need to know the most efficient way of installing JQ on Mac (el capitan). The code is downloaded to my mac but I would like to know how I can install and operate the via the c

5条回答
  •  余生分开走
    2021-01-31 13:58

    The simplest way to install jq and test that it works is through brew and then using the simplest filter that merely formats the JSON

    Install

    brew is the easiest way to manage packages on a mac:

    brew install jq
    

    Need brew? Run the following command:

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    

    Failing that: instructions to install and use are on https://brew.sh/

    Test

    The . filter takes its input and produces it unchanged as output. This is the identity operator. (quote the docs)

    echo '{ "name":"John", "age":31, "city":"New York" }' | jq .
    

    The result should appear like so in your terminal:

    {
      "name": "John",
      "age": 31,
      "city": "New York"
    }
    

提交回复
热议问题