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

Example on clearing None objects in lists #124

Open
LuisValverde1296 opened this issue Mar 13, 2024 · 0 comments
Open

Example on clearing None objects in lists #124

LuisValverde1296 opened this issue Mar 13, 2024 · 0 comments

Comments

@LuisValverde1296
Copy link

I haven an example where I want to extract a property from an object that could or could not be in 2 different fields hence it's an OR behavior.

So here are 3 possible values for this object:
{"first_level": {"second_level": {"first_place": {"property": "aimed_value"}, "second_place": {"property": "another_aimed_value"}}}}
{"first_level": {"second_level": {"first_place": {"property": "aimed_value"}}}}
{"first_level": {"second_level": {"second_place": {"property": "another_aimed_value"}}}}

Found this expression: "first_level.second_level.[first_place.property,second_place.property]"

And these are the possible results:
["aimed_value", "another_aimed_value"]
["aimed_value", None]
[None, "another_aimed_value"]

I didn't want this and didn't find any examples for cleaning this data, but fooling around I realized that adding [] at the end of the expression removes the None values from the results. This would be great to have displayed on the examples section.

So this is the final expression: "first_level.second_level.[first_place.property,second_place.property][]"

And these are the final results:
["aimed_value", "another_aimed_value"]
["aimed_value"]
["another_aimed_value"]

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