I have the following in a file (which I will call "myfile"):
[{
"id": 123,
"name": "John",
"aux": [{
"abc": "random",
"def": "I want this"
}],
"blah": 23.11
}]
I can parse it without the [
and ]
as follows:
$ cat myfile | jq -r '.aux[] | .def'
I want this
$
but with the [
and ]
I get:
$ cat myfile | jq -r '.aux[] | .def'
jq: error: Cannot index array with string
How can I deal with the [
and ]
using jq? (I'm sure I could parse them off with a different tool but I want to learn correct usage of jq.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…