I have the following JSON (which can be retrieved from https://openlibrary.org/api/books?bibkeys=ISBN:039397281X&format=json) as input:
{
"ISBN:039397281X": {
"bib_key": "ISBN:039397281X",
"preview": "borrow",
"thumbnail_url": "https://covers.openlibrary.org/b/id/7890978-S.jpg",
"preview_url": "https://archive.org/details/isbn_9780393972818",
"info_url": "https://openlibrary.org/books/OL348852M/Don_Quijote"
}
}
My goal is to extract the preview_url -- thus, for the input above, to get the output https://archive.org/details/isbn_9780393972818.
I'm currently using the following:
curl 'https://openlibrary.org/api/books?bibkeys=ISBN:039397281X&format=json' \
| jq -r '.ISBN:039397281X' | jq -r '.preview_url'
However, this emits an error:
jq: error: syntax error, unexpected ':', expecting $end (Unix shell quoting issues?) at <top-level>, line 1:
.ISBN:039397281X
jq: 1 compile error
How can it be resolved?