type
status
date
slug
summary
tags
category
icon
password

簡介

jq 就像是專門用於 json 檔案的 sed,可以對 json 檔案進行分片、過濾、映射和轉換,就和使用 sedawkgrep 等指令一樣都可以讓使用者輕鬆玩轉 text
jq 可以輕鬆地把 json 檔案轉換成使用者期望的格式,並且撰寫出來的程式會比原本預期的更短更簡單。此外, jq 使用 C 語言編寫,運行時沒有其他依賴,所以幾乎可以運行在任何系統上,下載下來的 binary 檔可以直接在 LinuxOS Xwindows 系統上運行。

安裝

command

options

--compact-output / -c

jq 預設會輸出 pretty-prints JSON,使用該參數則只會輸出緊湊單行的 JSON 。

--null-input / -n

--raw-output / -r

當結果是字符串時,則不將其格式化為帶引號的 JSON 字符串。

使用

以下為範例 json 文檔
jq . 是最簡單的使用方式,只會輸出好看的 json 格式,便於閱讀
 

參考