将简单的 json 数组转换为纯文本
convert simple json array to plain text
我当前使用的命令是:
curl -H "Accept: application/vnd.github.full+json" -H "Authorization: 7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b" "https://api.github.com/repos/zsh-users/zsh-syntax-highlighting/git/trees/master?recursive=1" | jq '.tree[]|.path'
我有一个 return 值
[
".editorconfig",
".gitattributes",
".gitignore",
".revision-hash",
".travis.yml",
".version",
"COPYING.md",
"HACKING.md",
"INSTALL.md",
"Makefile",
"README.md",
"changelog.md",
"docs",
"docs/highlighters.md",
"docs/highlighters",
"docs/highlighters/brackets.md",
"docs/highlighters/cursor.md",
"docs/highlighters/line.md",
.....
]
我希望 return 值类似于
.editorconfig
.gitattributes
.gitignore
.revision-hash
.travis.yml
.version
COPYING.md
HACKING.md
INSTALL.md
Makefile
README.md
changelog.md
docs
docs/highlighters.md
docs/highlighters
docs/highlighters/brackets.md
docs/highlighters/cursor.md
docs/highlighters/line.md
....
jq -r '.tree[]|.path' < <(curl -H "Accept: application/vnd.github.full+json" -H "Authorization: <MY-KEY>" "https://api.github.com/repos/zsh-users/zsh-syntax-highlighting/git/trees/master?recursive=1")
这使用 bash Process Substitution 所以答案中有趣的部分首先出现。你可以写 curl ... | jq ...
结果:
editorconfig
.gitattributes
.gitignore
.revision-hash
.travis.yml
.version
COPYING.md
HACKING.md
...
我当前使用的命令是:
curl -H "Accept: application/vnd.github.full+json" -H "Authorization: 7c258a9869f33c1e1e1f74fbb32f07c86cb5a75b" "https://api.github.com/repos/zsh-users/zsh-syntax-highlighting/git/trees/master?recursive=1" | jq '.tree[]|.path'
我有一个 return 值
[
".editorconfig",
".gitattributes",
".gitignore",
".revision-hash",
".travis.yml",
".version",
"COPYING.md",
"HACKING.md",
"INSTALL.md",
"Makefile",
"README.md",
"changelog.md",
"docs",
"docs/highlighters.md",
"docs/highlighters",
"docs/highlighters/brackets.md",
"docs/highlighters/cursor.md",
"docs/highlighters/line.md",
.....
]
我希望 return 值类似于
.editorconfig
.gitattributes
.gitignore
.revision-hash
.travis.yml
.version
COPYING.md
HACKING.md
INSTALL.md
Makefile
README.md
changelog.md
docs
docs/highlighters.md
docs/highlighters
docs/highlighters/brackets.md
docs/highlighters/cursor.md
docs/highlighters/line.md
....
jq -r '.tree[]|.path' < <(curl -H "Accept: application/vnd.github.full+json" -H "Authorization: <MY-KEY>" "https://api.github.com/repos/zsh-users/zsh-syntax-highlighting/git/trees/master?recursive=1")
这使用 bash Process Substitution 所以答案中有趣的部分首先出现。你可以写 curl ... | jq ...
结果:
editorconfig
.gitattributes
.gitignore
.revision-hash
.travis.yml
.version
COPYING.md
HACKING.md
...