# jq JSON 剖析器

## 介紹

jq 是輕量級且靈活的命令行 JSON 處理器。

## 下載

mac os 系統可以使用 brew 套件管理器安裝\
`brew install jq`

{% embed url="<https://stedolan.github.io/jq/>" %}

其他系統可以參考官網

## 簡易說明

`$ jq '.name' fileName.json`\
取得 fileName.json 裡的 name 鍵的值\
例如："name": "Andy"\
取得 "Andy"

`$ jq '.students[].name' fileName.json`\
取得 fileName.json 裡的\
students 陣列裡的 name 鍵的值

例如：

```
"students": [
    {
      "name": "student1",
      "number": "1"
    },
    {
      "name": "student2",
      "number": "2"
    }
  ]
```

取得：\
"student1"\
"student2"


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kanneg881.gitbook.io/workspace/zhong-duan/zhi-ling/bash/ling-wai-an-zhuang-de-zhi-ling/jq-json-pou-xi-qi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
