【发布时间】:2018-03-13 03:43:08
【问题描述】:
我有这个函数,它使用curl 和jq 作为 JSON 处理器迭代给定 JSON 的键,我的代码如下所示:(bash)
function getJSONContent {
option=""
for option in "header" "developer" "category" "description"
do
content=$(curl -s $extension_url | jq ".[\"$extension\"][\"$option\"]")
printf "$content\n"
done
}
但问题是它卷曲了 4 次,我还没有找到更好的解决方案而不会出错。
这样做可以吗?或者在 Bash / Shellscript 中是否有更好的解决方案?
【问题讨论】:
标签: json bash for-loop curl jq