Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find objects that do not have key #952

Closed
dbclkclk opened this issue Sep 17, 2015 · 5 comments
Closed

Find objects that do not have key #952

dbclkclk opened this issue Sep 17, 2015 · 5 comments
Labels

Comments

@dbclkclk
Copy link

I have these objects:

 {"id":"1", "name":"blah", "age":"12"}
 {"name":"blah", "age":"12"}

And I wanted a way to find the objects that do not contain the key "id". Is this possible?

@dtolnay
Copy link
Member

dtolnay commented Sep 17, 2015

Try this:

jq 'select(has("id") | not)'

@Nottt

This comment has been minimized.

@dtolnay

This comment has been minimized.

@Nottt

This comment has been minimized.

@Siva-Thilak
Copy link

Siva-Thilak commented Jan 8, 2021

I know it's been a while. But I had a simple question. What if the "id" here is an array?
and what if the array name has spaces in between .
For eg,
{"id":"1", "a b c":[ "name" : "foo" ] }
{"id":"2" }
and I want to display only first object that contains the array?
could you kindly help me on this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants