jq: nested object, extract top-level id and lift a value from internal object

interesting, the issue is indeed the “-” character and this works for me:

jq '.[] | { id, "info-spec": .stuff."info-spec" }' xample.json
{
  "id": 12345678,
  "info-spec": 12
}
{
  "id": 12345679,
  "info-spec": 23
}

yet your jq does not seem to like that syntax as it broke on the following and mine does not:

jq '.[] | .stuff."info-spec"' xample.json
12
23

I use:

jq --version
jq-1.4

edit: looks like a version issue with <1.4 indeed:
https://github.com/stedolan/jq/issues/38

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)