jq 无法使用字符串索引字符串 "value"

jq Cannot index string with string "value"

我有下面的短 jq 过滤器,它工作得很好:

cat data.tmp2 | ./jq-linux64-1.5 -r '.issues[].fields.customfield_10025 | if .value != null then (.value + "," + .child.value ) else "" end'

它产生的正是我所需要的,如果该字段为空,它 returns "" 如果该字段不为空,它使用该字段的值并连接一个逗号和一个子值。 但是,当我将过滤器移动到下面所示的更大过滤器中时,出现错误:无法使用字符串 "value"

索引字符串

这是失败的较长过滤器:

cat data.tmp2 | ./jq-linux64-1.5 -r '.issues | map([.key,.fields.project.name,.fields.parent.key,.fields.issuetype.name,.fields.status.name,.fields.priority.name,.fields.resolution.name,.fields.assignee.name,.fields.reporter.name,.fields.created,.fields.updated,.fields.resolutiondate,.fields.summary,(.fields.components | (map(.name?) | join (","))),(.fields.fixVersions | (map(.name?) | join (","))),.fields.customfield_10025 | if .value != null then (.value + "," + .child.value ) else "" end,.fields.customfield_10201] | join ("---"))

尝试在表达式两边加上括号:

.fields.customfield_10025 | if .value != null then (.value + "," + .child.value ) else "" end

[1,2 | type]被解析为[(1,2) | type],而不是[1, (2|type)]