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

map_values does not work? #80

Open
doowhtron opened this issue Nov 11, 2022 · 1 comment
Open

map_values does not work? #80

doowhtron opened this issue Nov 11, 2022 · 1 comment

Comments

@doowhtron
Copy link

doowhtron commented Nov 11, 2022

pyjq==2.4.0
jq version: 1.6

I wanna filter some certain objects with jq. Seems there's a bug with map_values function.

With jq, it works fine:

echo '{"a": {"status": 1, "elapsed": 12}, "b": {"status": 0, "elapsed": 11}}' | jq 'map_values(select(.status==1))'

returns:
{
  "a": {
    "status": 1,
    "elapsed": 12
  }
}

But with pyjq:

data={"a": {"status": 1, "elapsed": 12}, "b": {"status": 0, "elapsed": 11}}
pyjq.first('map_values(select(.status==1))', data)

returns
None

Try
pyjq.first('map_values(select(.status<1))', data)

returns
{'b': None}

@doowhtron
Copy link
Author

pyjq.first('to_entries| map(select(.value.status==1))', data) will work

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

No branches or pull requests

1 participant