Jq Cannot index row with string "value"

I have a short jq filter that works fine:

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

It produces exactly what I need, if the field is empty, it returns "", if the field is not empty, it uses the field value and combines the comma and child value. However, when I move my filter in the larger filter shown below, I get an error: Cannot index a row with the string "value"

This is a longer filter that fails:

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 ("---"))
+4
source share
1 answer

Try putting parentheses around the expression:

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

That is, it is [1,2 | type]analyzed as [(1,2) | type], but not [1, (2|type)].

+2
source

Source: https://habr.com/ru/post/1617318/


All Articles