Output specific key value in object for each element in array with jq for JSON

The command-line tool jq writes to STDOUT and/or STDERR. If you want to write the .AssetId information to STDOUT, then one possibility would be as follows:

jq -r ".[] | .AssetId" input.json

Output:

14462955
114385498
29715011
98253651

A more robust incantation would be: .[] | .AssetId? but your choice will depend on what you want if there is no key named “AssetId”.

Leave a Comment

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