Skip to content

Filter by any object in array #466

@purrplehaze

Description

@purrplehaze

Hi guys!

I have json with following structure:

{
    "territories":[
        {
            "type":"COUNTRY",
            "name":"UNITED STATES",
            "names":{
                "de":[
                    {
                        "name":"VEREINIGTE STAATEN",
                        "official":"VEREINIGTE STAATEN VON AMERIKA",
                        "abbrv":"VS",
                        "unofficial":""
                    }
                ],
                "en":[
                    {
                        "name":"UNITED STATES",
                        "official":"UNITED STATES OF AMERICA",
                        "abbrv":"USA",
                        "unofficial":""
                    }
                ]
            }
        }
    ]
}

I want to filter all root objects by querying any of objects in names.de array. So i have next expression:
$.territories[?(@.names.de[0].official == 'VEREINIGTE STAATEN VON AMERIKA')]

The problem is in de[0] part because I should explicitly specify index of object to search.
I suggested that de[*] would solve this, but it's not working at all.

So, what are possible options to solve this issue?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions