Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 527

jq: error Cannot index string with string "value"

$
0
0

Given:

MY_JSON=$(cat <<EOF{"schema": "my.schema","properties": [    {"type": "new.data","value": {"labels": {"ofasd.io/arch.amd64": "supported","ofasd.io/arch.arm64": "supported","ofasd.io/arch.ppc64le": "supported","ofasd.io/arch.s390x": "unsupported"        }      }    }  ]}EOF)

I'm trying to filter only "supported" architectures:

arches=$(echo "$MY_JSON" | tr -d '\000-\031' | jq -r '.properties[] | select(.type == "new.data") | .value.labels | to_entries | map(select(.key | test("^ofasd\\.io/arch\\.") and .value == "supported")) | map(.key | sub("^ofasd\\.io/arch\\."; "")) | join("\n")')

Expected output:

amd64arm64ppc64le

Actual output:

jq: error (at <stdin>:0): Cannot index string with string "value"

Could someone please help me understand what I'm doing wrong?It seems like the issue is that ofasd.io/arch.* filtering is not working.When I run:

echo "$MY_JSON" | jq -r '.properties[] | select(.type == "new.data") | .value.labels | to_entries | map(select(.key | test("^ofasd.io/arch\\.") and .value == "supported"))'

I get:

echo "$MY_JSON" | jq -r '' failed with status 5

Viewing all articles
Browse latest Browse all 527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>