I am trying to pass two variables into a jq query.
My JSON
{
"AlbumTitle": "Name Of Album",
"AlbumLink": "/album/link/id/1/album-name/",
"ArtistName": "Artist Name",
"Date": "September 14, 2018"
},
{
"AlbumTitle": "Name Of Album",
"AlbumLink": "/album/link/id/2/album-name/",
"ArtistName": "Artist Name",
"Date": "September 13, 2018"
}
I two variables as the Date and Artist Name, and I am trying to pull back the ArtistLink depending on the variables.
I am using the JQ line below.
cat test.json | jq -n -r --arg TESTDATE "$TESTDATE" '.. | objects | {select(.Date == '"$TESTDATE"')} | select(.ArtistName | contains('"$test1"')) | .AlbumLink'
And I am getting the error
"jq: error: syntax error, unexpected '(', expecting '}' (Unix shell quoting issues?) at <top-level>, line 1:
.. | objects | {select(.Date == September 13, 2018)} | select(.ArtistName | contains(Artist)) | .AlbumLink
jq: 1 compile error"