I'm trying to parse out some of the AWS price API json results and noticed that I'm getting some errors on string and object validation, but can't figure out how to debug which object or string jq
is choking on.
Could someone help point me in the right direction? I've tried changing endswith
to startswith
as well as contains, but all exhibit different errors, so I haven't been able to narrow the object in error (probably doesn't help the json response is 1.1M+ lines...)
Interestingly enough, using endswith($type)
gets me the sku i'm looking for, but also returns jq: jv.c:721: jv_string_value: Assertion 'jv_get_kind(j) == JV_KIND_STRING' failed.
I tried looking at line 721 in jv.c, but I don't really know C, so I'm kinda stuck.
Thanks in advance.
SCRIPT:
#!/bin/bashtype="hs1.8xlarge"curl -s -L -k https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json | jq --arg type "$type"'.products[] | select(.attributes.instanceType | endswith($type)).sku'