Skip to content

Example on clearing None objects in lists #124

@LuisValverde1296

Description

@LuisValverde1296

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"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions