Issue
I have a Pipfile.lock JSON file that I need to parse with the jq
tool. The structure of the file is:
{
//...
"default": {
"value1": {
// lots of nested properties with values
},
"value2": {
//similar stuff as for value1
}
//...
}
}
What do now is jq '.default | keys' Pipfile.lock
which produces:
[
"value1",
"value2",
...
]
I would need the output to:
- Not produce the first line with
[
and last line with]
- Have the values printed without quotes
Is this feasible just using jq
?
Solution
You want the elements of the array, not the array itself.
jq '.default | keys[]' Pipfile.lock
Use the -r
option to output raw strings, rather than JSON strings.
jq -r '.default | keys[]' Pipfile.lock
Answered By - chepner Answer Checked By - Marie Seifert (WPSolving Admin)