Published
- 1 min read
select not null jq
The solution for this is noted below
select not null jq
Solution
JSON='[
{
"id": 1,
"name": "John"
},
{
"id": 2,
"name": null
}
]'
echo $JSON | jq '.[] | select(.name != null)'
# Output
{
"id": 1,
"name": "John"
}
echo $JSON | jq '.[] | select(.name != null) | .name'
# Output
"John"
Try other methods by searching on the site. That is if this doesn’t work