[Python] ObjectPath nested query problem with nested filter

Discussão em 'Python' iniciado por Stack, Maio 13, 2025.

  1. Stack

    Stack Membro Participativo

    I have this expression string in ObjectPath Python, I want to filter list of incoming json input if it fits the criteria below:

    expression_string = """
    $..*[
    @.api_name is "X" and
    @.raw_record.event.parameters[@.name is "some_field" and @.value is "lala"] and
    @.raw_record.event.parameters[@.name is "some_field2" and @.value in ["val1", "val2", "val3", "val4"]]
    ]
    """


    and each of my input something like this

    {
    # --- First record (should match) ---
    "api_name": "copy",
    "api_status": "Success",
    "breez_identity_type": "human",
    "raw_record": {
    "event": {
    "parameters": [

    {"name": "some_field", "value": "lala"}, # should match criteria
    {"name": "other_field", "value": "random_val"},
    ],
    }
    }
    }


    but it doesn't match, any idea?

    Continue reading...

Compartilhe esta Página