[英]json jq array to string with double quotes
I am trying to convert an array to string and would like to be:我正在尝试将数组转换为字符串,并希望成为:
declare -r LOCAL_VERSIONS=(
"1.3.17"
"1.3.18"
"1.3.19"
"1.3.20"
"1.4.0-beta.1"
"1.4.0-beta.1"
"1.4.0-beta.2"
"1.4.0"
"1.4.1"
"1.4.2"
"1.4.3"
"1.4.4"
"1.5.0-beta.1"
"1.5.0"
"1.5.1"
"1.5.2"
)
The best I got so far is:到目前为止我得到的最好的是:
declare -r VERSIONS=(=${VERSIONS:-$(curl -s https://api.github.com/repos/humhub/humhub/releases | jq -r '.[] | [.name] | join(" ")')})
which outputs:输出:
1.5.1
1.5.0
1.5.0-beta.1
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.20
1.3.19
1.4.0-beta.2
1.3.18
1.4.0-beta.1
1.3.17
1.3.9
1.3.8
1.3.7
1.3.6
1.3.5
1.3.4
1.3.3
1.3.2
How I can achieve as LOCAL_VERSIONS using curl (meaning getting versions from GitHub)?如何使用 curl 实现 LOCAL_VERSIONS (意思是从 GitHub 获取版本)?
The -r
in jq -r
removed quotes, this is what's needed: jq -r
-r
的 -r 删除了引号,这是需要的:
declare VERSIONS=($(curl -s https://api.github.com/repos/humhub/humhub/releases | jq '.[].name'))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.