Skip to content

Queries

Sascha Greuel edited this page Oct 30, 2020 · 12 revisions

Supported Queries

Below, you will find a list of queries, which are currently supported by this library. This list has been created, based on the great comparison list project by Christoph Burgmer.

Other queries might be supported too, but there's no consensus (aka expected result), therefore it is unclear if the results returned are correct, or not. A list of possibly supported queries can be found here.

Corresponding unit/functional tests for these specific queries can be found here.


Array Slice
Table of Contents

Array Slice

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[1:3]

Consensus:

[
    "second",
    "third"
]

Array Slice On Exact Match

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[0:5]

Consensus:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Array Slice On Non Overlapping Array

Test Data:

[
    "first",
    "second",
    "third"
]

Selector:

$[7:10]

Consensus:

[]

Array Slice On Object

Test Data:

{
    ":": 42,
    "more": "string",
    "a": 1,
    "b": 2,
    "c": 3,
    "1:3": "nice"
}

Selector:

$[1:3]

Consensus:

[]

Array Slice On Partially Overlapping Array

Test Data:

[
    "first",
    "second",
    "third"
]

Selector:

$[1:10]

Consensus:

[
    "second",
    "third"
]

Array Slice With Negative Start And End And Range Of -1

Test Data:

[
    2,
    "a",
    4,
    5,
    100,
    "nice"
]

Selector:

$[-4:-5]

Consensus:

[]

Array Slice With Negative Start And End And Range Of 0

Test Data:

[
    2,
    "a",
    4,
    5,
    100,
    "nice"
]

Selector:

$[-4:-4]

Consensus:

[]

Array Slice With Negative Start And End And Range Of 1

Test Data:

[
    2,
    "a",
    4,
    5,
    100,
    "nice"
]

Selector:

$[-4:-3]

Consensus:

[
    4
]

Array Slice With Negative Start And Positive End And Range Of -1

Test Data:

[
    2,
    "a",
    4,
    5,
    100,
    "nice"
]

Selector:

$[-4:1]

Consensus:

[]

Array Slice With Negative Start And Positive End And Range Of 0

Test Data:

[
    2,
    "a",
    4,
    5,
    100,
    "nice"
]

Selector:

$[-4:2]

Consensus:

[]

Array Slice With Negative Start And Positive End And Range Of 1

Test Data:

[
    2,
    "a",
    4,
    5,
    100,
    "nice"
]

Selector:

$[-4:3]

Consensus:

[
    4
]

Array Slice With Open End

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[1:]

Consensus:

[
    "second",
    "third",
    "forth",
    "fifth"
]

Array Slice With Open Start

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[:2]

Consensus:

[
    "first",
    "second"
]

Array Slice With Open Start And End

Test Data:

[
    "first",
    "second"
]

Selector:

$[:]

Consensus:

[
    "first",
    "second"
]

Array Slice With Open Start And End And Step Empty

Test Data:

[
    "first",
    "second"
]

Selector:

$[::]

Consensus:

[
    "first",
    "second"
]

Array Slice With Positive Start And Negative End And Range Of -1

Test Data:

[
    2,
    "a",
    4,
    5,
    100,
    "nice"
]

Selector:

$[3:-4]

Consensus:

[]

Array Slice With Positive Start And Negative End And Range Of 0

Test Data:

[
    2,
    "a",
    4,
    5,
    100,
    "nice"
]

Selector:

$[3:-3]

Consensus:

[]

Array Slice With Positive Start And Negative End And Range Of 1

Test Data:

[
    2,
    "a",
    4,
    5,
    100,
    "nice"
]

Selector:

$[3:-2]

Consensus:

[
    5
]

Array Slice With Range Of -1

Test Data:

[
    "first",
    "second",
    "third",
    "forth"
]

Selector:

$[2:1]

Consensus:

[]

Array Slice With Range Of 0

Test Data:

[
    "first",
    "second"
]

Selector:

$[0:0]

Consensus:

[]

Array Slice With Range Of 1

Test Data:

[
    "first",
    "second"
]

Selector:

$[0:1]

Consensus:

[
    "first"
]

Array Slice With Start -1 And Open End

Test Data:

[
    "first",
    "second",
    "third"
]

Selector:

$[-1:]

Consensus:

[
    "third"
]

Array Slice With Start -2 And Open End

Test Data:

[
    "first",
    "second",
    "third"
]

Selector:

$[-2:]

Consensus:

[
    "second",
    "third"
]

Array Slice With Start Large Negative Number And Open End On Short Array

Test Data:

[
    "first",
    "second",
    "third"
]

Selector:

$[-4:]

Consensus:

[
    "first",
    "second",
    "third"
]

Array Slice With Step

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[0:3:2]

Consensus:

[
    "first",
    "third"
]

Array Slice With Step 1

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[0:3:1]

Consensus:

[
    "first",
    "second",
    "third"
]

Array Slice With Step And Leading Zeros

Test Data:

[
    0,
    1,
    2,
    3,
    4,
    5,
    6,
    7,
    8,
    9,
    10,
    11,
    12,
    13,
    14,
    15,
    16,
    17,
    18,
    19,
    20,
    21,
    22,
    23,
    24,
    25
]

Selector:

$[010:024:010]

Consensus:

[
    10,
    20
]

Array Slice With Step But End Not Aligned

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[0:4:2]

Consensus:

[
    "first",
    "third"
]

Array Slice With Step Empty

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[1:3:]

Consensus:

[
    "second",
    "third"
]

Array Slice With Step Only

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[::2]

Consensus:

[
    "first",
    "third",
    "fifth"
]
Bracket Notation
Table of Contents

Bracket Notation

Test Data:

{
    "key": "value"
}

Selector:

$['key']

Consensus:

[
    "value"
]

Bracket Notation After Recursive Descent

Test Data:

[
    "first",
    {
        "key": [
            "first nested",
            {
                "more": [
                    {
                        "nested": [
                            "deepest",
                            "second"
                        ]
                    },
                    [
                        "more",
                        "values"
                    ]
                ]
            }
        ]
    }
]

Selector:

$..[0]

Consensus:

[
    "deepest",
    "first nested",
    "first",
    "more",
    {
        "nested": [
            "deepest",
            "second"
        ]
    }
]

Bracket Notation On Object Without Key

Test Data:

{
    "key": "value"
}

Selector:

$['missing']

Consensus:

[]

Bracket Notation With NFC Path On NFD Key

Test Data:

{
    "u\u0308": 42
}

Selector:

$['ü']

Consensus:

[]

Bracket Notation With Dot

Test Data:

{
    "one": {
        "key": "value"
    },
    "two": {
        "some": "more",
        "key": "other value"
    },
    "two.some": "42"
}

Selector:

$['two.some']

Consensus:

[
    "42"
]

Bracket Notation With Double Quotes

Test Data:

{
    "key": "value"
}

Selector:

$["key"]

Consensus:

[
    "value"
]

Bracket Notation With Empty String

Test Data:

{
    "": 42,
    "''": 123,
    "\"\"": 222
}

Selector:

$['']

Consensus:

[
    42
]

Bracket Notation With Empty String Doubled Quoted

Test Data:

{
    "": 42,
    "''": 123,
    "\"\"": 222
}

Selector:

$[""]

Consensus:

[
    42
]

Bracket Notation With Negative Number On Short Array

Test Data:

[
    "one element"
]

Selector:

$[-2]

Consensus:

[]

Bracket Notation With Number

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[2]

Consensus:

[
    "third"
]

Bracket Notation With Number -1

Test Data:

[
    "first",
    "second",
    "third"
]

Selector:

$[-1]

Consensus:

[
    "third"
]

Bracket Notation With Number -1 On Empty Array

Test Data:

[]

Selector:

$[-1]

Consensus:

[]

Bracket Notation With Number 0

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[0]

Consensus:

[
    "first"
]

Bracket Notation With Number After Dot Notation With Wildcard On Nested Arrays With Different Length

Test Data:

[
    [
        1
    ],
    [
        2,
        3
    ]
]

Selector:

$.*[1]

Consensus:

[
    3
]

Bracket Notation With Number On Short Array

Test Data:

[
    "one element"
]

Selector:

$[1]

Consensus:

[]

Bracket Notation With Quoted Array Slice Literal

Test Data:

{
    ":": "value",
    "another": "entry"
}

Selector:

$[':']

Consensus:

[
    "value"
]

Bracket Notation With Quoted Closing Bracket Literal

Test Data:

{
    "]": 42
}

Selector:

$[']']

Consensus:

[
    42
]

Bracket Notation With Quoted Current Object Literal

Test Data:

{
    "@": "value",
    "another": "entry"
}

Selector:

$['@']

Consensus:

[
    "value"
]

Bracket Notation With Quoted Dot Literal

Test Data:

{
    ".": "value",
    "another": "entry"
}

Selector:

$['.']

Consensus:

[
    "value"
]

Bracket Notation With Quoted Dot Wildcard

Test Data:

{
    "key": 42,
    ".*": 1,
    "": 10
}

Selector:

$['.*']

Consensus:

[
    1
]

Bracket Notation With Quoted Double Quote Literal

Test Data:

{
    "\"": "value",
    "another": "entry"
}

Selector:

$['"']

Consensus:

[
    "value"
]

Bracket Notation With Quoted Number On Object

Test Data:

{
    "0": "value"
}

Selector:

$['0']

Consensus:

[
    "value"
]

Bracket Notation With Quoted Root Literal

Test Data:

{
    "$": "value",
    "another": "entry"
}

Selector:

$['$']

Consensus:

[
    "value"
]

Bracket Notation With Quoted Union Literal

Test Data:

{
    ",": "value",
    "another": "entry"
}

Selector:

$[',']

Consensus:

[
    "value"
]

Bracket Notation With Quoted Wildcard Literal

Test Data:

{
    "*": "value",
    "another": "entry"
}

Selector:

$['*']

Consensus:

[
    "value"
]

Bracket Notation With String Including Dot Wildcard

Test Data:

{
    "nice": 42,
    "ni.*": 1,
    "mice": 100
}

Selector:

$['ni.*']

Consensus:

[
    1
]

Bracket Notation With Wildcard After Array Slice

Test Data:

[
    [
        1,
        2
    ],
    [
        "a",
        "b"
    ],
    [
        0,
        0
    ]
]

Selector:

$[0:2][*]

Consensus:

[
    1,
    2,
    "a",
    "b"
]

Bracket Notation With Wildcard After Dot Notation After Bracket Notation With Wildcard

Test Data:

[
    {
        "bar": [
            42
        ]
    }
]

Selector:

$[*].bar[*]

Consensus:

[
    42
]

Bracket Notation With Wildcard After Recursive Descent

Test Data:

{
    "key": "value",
    "another key": {
        "complex": "string",
        "primitives": [
            0,
            1
        ]
    }
}

Selector:

$..[*]

Consensus:

[
    "string",
    "value",
    0,
    1,
    [
        0,
        1
    ],
    {
        "complex": "string",
        "primitives": [
            0,
            1
        ]
    }
]

Bracket Notation With Wildcard On Array

Test Data:

[
    "string",
    42,
    {
        "key": "value"
    },
    [
        0,
        1
    ]
]

Selector:

$[*]

Consensus:

[
    "string",
    42,
    {
        "key": "value"
    },
    [
        0,
        1
    ]
]

Bracket Notation With Wildcard On Empty Array

Test Data:

[]

Selector:

$[*]

Consensus:

[]

Bracket Notation With Wildcard On Empty Object

Test Data:

{}

Selector:

$[*]

Consensus:

[]

Bracket Notation With Wildcard On Null Value Array

Test Data:

[
    40,
    null,
    42
]

Selector:

$[*]

Consensus:

[
    40,
    null,
    42
]

Bracket Notation With Wildcard On Object

Test Data:

{
    "some": "string",
    "int": 42,
    "object": {
        "key": "value"
    },
    "array": [
        0,
        1
    ]
}

Selector:

$[*]

Consensus:

[
    "string",
    42,
    [
        0,
        1
    ],
    {
        "key": "value"
    }
]
Dot Notation
Table of Contents

Dot Notation

Test Data:

{
    "key": "value"
}

Selector:

$.key

Consensus:

[
    "value"
]

Dot Notation After Array Slice

Test Data:

[
    {
        "key": "ey"
    },
    {
        "key": "bee"
    },
    {
        "key": "see"
    }
]

Selector:

$[0:2].key

Consensus:

[
    "ey",
    "bee"
]

Dot Notation After Bracket Notation After Recursive Descent

Test Data:

{
    "k": [
        {
            "key": "some value"
        },
        {
            "key": 42
        }
    ],
    "kk": [
        [
            {
                "key": 100
            },
            {
                "key": 200
            },
            {
                "key": 300
            }
        ],
        [
            {
                "key": 400
            },
            {
                "key": 500
            },
            {
                "key": 600
            }
        ]
    ],
    "key": [
        0,
        1
    ]
}

Selector:

$..[1].key

Consensus:

[
    200,
    42,
    500
]

Dot Notation After Bracket Notation With Wildcard

Test Data:

[
    {
        "a": 1
    },
    {
        "a": 1
    }
]

Selector:

$[*].a

Consensus:

[
    1,
    1
]

Dot Notation After Bracket Notation With Wildcard On One Matching

Test Data:

[
    {
        "a": 1
    }
]

Selector:

$[*].a

Consensus:

[
    1
]

Dot Notation After Bracket Notation With Wildcard On Some Matching

Test Data:

[
    {
        "a": 1
    },
    {
        "b": 1
    }
]

Selector:

$[*].a

Consensus:

[
    1
]

Dot Notation After Filter Expression

Test Data:

[
    {
        "id": 42,
        "name": "forty-two"
    },
    {
        "id": 1,
        "name": "one"
    }
]

Selector:

$[?(@.id==42)].name

Consensus:

[
    "forty-two"
]

Dot Notation After Recursive Descent

Test Data:

{
    "object": {
        "key": "value",
        "array": [
            {
                "key": "something"
            },
            {
                "key": {
                    "key": "russian dolls"
                }
            }
        ]
    },
    "key": "top"
}

Selector:

$..key

Consensus:

[
    "russian dolls",
    "something",
    "top",
    "value",
    {
        "key": "russian dolls"
    }
]

Dot Notation After Recursive Descent After Dot Notation

Test Data:

{
    "store": {
        "book": [
            {
                "category": "reference",
                "author": "Nigel Rees",
                "title": "Sayings of the Century",
                "price": 8.95
            },
            {
                "category": "fiction",
                "author": "Evelyn Waugh",
                "title": "Sword of Honour",
                "price": 12.99
            },
            {
                "category": "fiction",
                "author": "Herman Melville",
                "title": "Moby Dick",
                "isbn": "0-553-21311-3",
                "price": 8.99
            },
            {
                "category": "fiction",
                "author": "J. R. R. Tolkien",
                "title": "The Lord of the Rings",
                "isbn": "0-395-19395-8",
                "price": 22.99
            }
        ],
        "bicycle": {
            "color": "red",
            "price": 19.95
        }
    }
}

Selector:

$.store..price

Consensus:

[
    12.99,
    19.95,
    22.99,
    8.95,
    8.99
]

Dot Notation After Union

Test Data:

[
    {
        "key": "ey"
    },
    {
        "key": "bee"
    },
    {
        "key": "see"
    }
]

Selector:

$[0,2].key

Consensus:

[
    "ey",
    "see"
]

Dot Notation After Union With Keys

Test Data:

{
    "one": {
        "key": "value"
    },
    "two": {
        "k": "v"
    },
    "three": {
        "some": "more",
        "key": "other value"
    }
}

Selector:

$['one','three'].key

Consensus:

[
    "value",
    "other value"
]

Dot Notation On Array

Test Data:

[
    0,
    1
]

Selector:

$.key

Consensus:

[]

Dot Notation On Array Value

Test Data:

{
    "key": [
        "first",
        "second"
    ]
}

Selector:

$.key

Consensus:

[
    [
        "first",
        "second"
    ]
]

Dot Notation On Array With Containing Object Matching Key

Test Data:

[
    {
        "id": 2
    }
]

Selector:

$.id

Consensus:

[]

Dot Notation On Empty Object Value

Test Data:

{
    "key": {}
}

Selector:

$.key

Consensus:

[
    {}
]

Dot Notation On Null Value

Test Data:

{
    "key": null
}

Selector:

$.key

Consensus:

[
    null
]

Dot Notation On Object Without Key

Test Data:

{
    "key": "value"
}

Selector:

$.missing

Consensus:

[]

Dot Notation With Dash

Test Data:

{
    "key-dash": "value"
}

Selector:

$.key-dash

Consensus:

[
    "value"
]

Dot Notation With Key Named In

Test Data:

{
    "in": "value"
}

Selector:

$.in

Consensus:

[
    "value"
]

Dot Notation With Key Named Length

Test Data:

{
    "length": "value"
}

Selector:

$.length

Consensus:

[
    "value"
]

Dot Notation With Key Named Length On Array

Test Data:

[
    4,
    5,
    6
]

Selector:

$.length

Consensus:

[]

Dot Notation With Key Named Null

Test Data:

{
    "null": "value"
}

Selector:

$.null

Consensus:

[
    "value"
]

Dot Notation With Key Named True

Test Data:

{
    "true": "value"
}

Selector:

$.true

Consensus:

[
    "value"
]

Dot Notation With Non ASCII Key

Test Data:

{
    "\u5c6c\u6027": "value"
}

Selector:

$.屬性

Consensus:

[
    "value"
]

Dot Notation With Number On Object

Test Data:

{
    "a": "first",
    "2": "second",
    "b": "third"
}

Selector:

$.2

Consensus:

[
    "second"
]

Dot Notation With Wildcard After Dot Notation After Dot Notation With Wildcard

Test Data:

[
    {
        "bar": [
            42
        ]
    }
]

Selector:

$.*.bar.*

Consensus:

[
    42
]

Dot Notation With Wildcard After Dot Notation With Wildcard On Nested Arrays

Test Data:

[
    [
        1,
        2,
        3
    ],
    [
        4,
        5,
        6
    ]
]

Selector:

$.*.*

Consensus:

[
    1,
    2,
    3,
    4,
    5,
    6
]

Dot Notation With Wildcard After Recursive Descent

Test Data:

{
    "key": "value",
    "another key": {
        "complex": "string",
        "primitives": [
            0,
            1
        ]
    }
}

Selector:

$..*

Consensus:

[
    "string",
    "value",
    0,
    1,
    [
        0,
        1
    ],
    {
        "complex": "string",
        "primitives": [
            0,
            1
        ]
    }
]

Dot Notation With Wildcard After Recursive Descent On Null Value Array

Test Data:

[
    40,
    null,
    42
]

Selector:

$..*

Consensus:

[
    40,
    42,
    null
]

Dot Notation With Wildcard After Recursive Descent On Scalar

Test Data:

42

Selector:

$..*

Consensus:

[]

Dot Notation With Wildcard On Array

Test Data:

[
    "string",
    42,
    {
        "key": "value"
    },
    [
        0,
        1
    ]
]

Selector:

$.*

Consensus:

[
    "string",
    42,
    {
        "key": "value"
    },
    [
        0,
        1
    ]
]

Dot Notation With Wildcard On Empty Array

Test Data:

[]

Selector:

$.*

Consensus:

[]

Dot Notation With Wildcard On Empty Object

Test Data:

{}

Selector:

$.*

Consensus:

[]

Dot Notation With Wildcard On Object

Test Data:

{
    "some": "string",
    "int": 42,
    "object": {
        "key": "value"
    },
    "array": [
        0,
        1
    ]
}

Selector:

$.*

Consensus:

[
    "string",
    42,
    [
        0,
        1
    ],
    {
        "key": "value"
    }
]
Filter Expression
Table of Contents

Filter Expression With Bracket Notation

Test Data:

[
    {
        "key": 0
    },
    {
        "key": 42
    },
    {
        "key": -1
    },
    {
        "key": 41
    },
    {
        "key": 43
    },
    {
        "key": 42.0001
    },
    {
        "key": 41.9999
    },
    {
        "key": 100
    },
    {
        "some": "value"
    }
]

Selector:

$[?(@['key']==42)]

Consensus:

[
    {
        "key": 42
    }
]

Filter Expression With Bracket Notation And Current Object Literal

Test Data:

[
    {
        "@key": 0
    },
    {
        "@key": 42
    },
    {
        "key": 42
    },
    {
        "@key": 43
    },
    {
        "some": "value"
    }
]

Selector:

$[?(@['@key']==42)]

Consensus:

[
    {
        "@key": 42
    }
]

Filter Expression With Bracket Notation With Number

Test Data:

[
    [
        "a",
        "b"
    ],
    [
        "x",
        "y"
    ]
]

Selector:

$[?(@[1]=='b')]

Consensus:

[
    [
        "a",
        "b"
    ]
]

Filter Expression With Equals On Array Without Match

Test Data:

[
    {
        "key": 42
    }
]

Selector:

$[?(@.key==43)]

Consensus:

[]

Filter Expression With Equals String With Current Object Literal

Test Data:

[
    {
        "key": "some"
    },
    {
        "key": "value"
    },
    {
        "key": "[email protected]"
    }
]

Selector:

$[?(@.key=="[email protected]")]

Consensus:

[
    {
        "key": "[email protected]"
    }
]

Filter Expression With Equals String With Dot Literal

Test Data:

[
    {
        "key": "some"
    },
    {
        "key": "value"
    },
    {
        "key": "some.value"
    }
]

Selector:

$[?(@.key=="some.value")]

Consensus:

[
    {
        "key": "some.value"
    }
]

Filter Expression With Equals String With Single Quotes

Test Data:

[
    {
        "key": "some"
    },
    {
        "key": "value"
    }
]

Selector:

$[?(@.key=='value')]

Consensus:

[
    {
        "key": "value"
    }
]

Filter Expression With Subpaths

Test Data:

[
    {
        "address": {
            "city": "Berlin"
        }
    },
    {
        "address": {
            "city": "London"
        }
    }
]

Selector:

$[?(@.address.city=='Berlin')]

Consensus:

[
    {
        "address": {
            "city": "Berlin"
        }
    }
]
Root
Table of Contents

Root

Test Data:

{
    "key": "value",
    "another key": {
        "complex": [
            "a",
            1
        ]
    }
}

Selector:

$

Consensus:

[
    {
        "another key": {
            "complex": [
                "a",
                1
            ]
        },
        "key": "value"
    }
]

Root On Scalar

Test Data:

42

Selector:

$

Consensus:

[
    42
]

Root On Scalar False

Test Data:

false

Selector:

$

Consensus:

[
    false
]

Root On Scalar True

Test Data:

true

Selector:

$

Consensus:

[
    true
]
Union
Table of Contents

Union

Test Data:

[
    "first",
    "second",
    "third"
]

Selector:

$[0,1]

Consensus:

[
    "first",
    "second"
]

Union With Keys

Test Data:

{
    "key": "value",
    "another": "entry"
}

Selector:

$['key','another']

Consensus:

[
    "value",
    "entry"
]

Union With Keys After Array Slice

Test Data:

[
    {
        "c": "cc1",
        "d": "dd1",
        "e": "ee1"
    },
    {
        "c": "cc2",
        "d": "dd2",
        "e": "ee2"
    }
]

Selector:

$[:]['c','d']

Consensus:

[
    "cc1",
    "dd1",
    "cc2",
    "dd2"
]

Union With Keys After Bracket Notation

Test Data:

[
    {
        "c": "cc1",
        "d": "dd1",
        "e": "ee1"
    },
    {
        "c": "cc2",
        "d": "dd2",
        "e": "ee2"
    }
]

Selector:

$[0]['c','d']

Consensus:

[
    "cc1",
    "dd1"
]

Union With Keys On Object Without Key

Test Data:

{
    "key": "value",
    "another": "entry"
}

Selector:

$['missing','key']

Consensus:

[
    "value"
]

Union With Numbers In Decreasing Order

Test Data:

[
    1,
    2,
    3,
    4,
    5
]

Selector:

$[4,1]

Consensus:

[
    5,
    2
]

Union With Spaces

Test Data:

[
    "first",
    "second",
    "third"
]

Selector:

$[ 0 , 1 ]

Consensus:

[
    "first",
    "second"
]

Possibly supported queries

Below, you will find a list of queries, which are possibly supported by this library. Possibly means, that there's no consensus (aka expected result), therefore it is unclear if the results returned are correct, or not.

Array Slice
Table of Contents

Array Slice With Large Number For End And Negative Step

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[2:-113667776004:-1]

Array Slice With Large Number For Start End Negative Step

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[113667776004:2:-1]

Array Slice With Negative Step

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[3:0:-2]

Array Slice With Negative Step On Partially Overlapping Array

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[7:3:-1]

Array Slice With Open Start And End On Object

Test Data:

{
    ":": 42,
    "more": "string"
}

Selector:

$[:]

Array Slice With Step 0

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[0:3:0]
Bracket Notation
Table of Contents

Bracket Notation With Empty Path

Test Data:

{
    "": 42,
    "''": 123,
    "\"\"": 222
}

Selector:

$[]

Bracket Notation With Number On Object

Test Data:

{
    "0": "value"
}

Selector:

$[0]

Bracket Notation With Number On String

Test Data:

"Hello World"

Selector:

$[0]

Bracket Notation With Quoted Escaped Backslash

Test Data:

{
    "\\": "value"
}

Selector:

$['\\']

Bracket Notation With Quoted Escaped Single Quote

Test Data:

{
    "'": "value"
}

Selector:

$['\'']

Bracket Notation With Quoted Special Characters Combined

Test Data:

{
    ":@.\"$,*'\\": 42
}

Selector:

$[':@."$,*\'\\']

Bracket Notation With Quoted String And Unescaped Single Quote

Test Data:

{
    "single'quote": "value"
}

Selector:

$['single'quote']

Bracket Notation With Quoted Wildcard Literal On Object Without Key

Test Data:

{
    "another": "entry"
}

Selector:

$['*']

Bracket Notation With Two Literals Separated By Dot

Test Data:

{
    "one": {
        "key": "value"
    },
    "two": {
        "some": "more",
        "key": "other value"
    },
    "two.some": "42",
    "two'.'some": "43"
}

Selector:

$['two'.'some']

Bracket Notation With Two Literals Separated By Dot Without Quotes

Test Data:

{
    "one": {
        "key": "value"
    },
    "two": {
        "some": "more",
        "key": "other value"
    },
    "two.some": "42"
}

Selector:

$[two.some]

Bracket Notation Without Quotes

Test Data:

{
    "key": "value"
}

Selector:

$[key]

Dot Bracket Notation

Test Data:

{
    "key": "value",
    "other": {
        "key": [
            {
                "key": 42
            }
        ]
    }
}

Selector:

$.['key']

Dot Bracket Notation With Double Quotes

Test Data:

{
    "key": "value",
    "other": {
        "key": [
            {
                "key": 42
            }
        ]
    }
}

Selector:

$.["key"]

Dot Bracket Notation Without Quotes

Test Data:

{
    "key": "value",
    "other": {
        "key": [
            {
                "key": 42
            }
        ]
    }
}

Selector:

$.[key]

Dot Notation With Double Quotes

Test Data:

{
    "key": "value",
    "\"key\"": 42
}

Selector:

$."key"

Dot Notation With Double Quotes After Recursive Descent

Test Data:

{
    "object": {
        "key": "value",
        "\"key\"": 100,
        "array": [
            {
                "key": "something",
                "\"key\"": 0
            },
            {
                "key": {
                    "key": "russian dolls"
                },
                "\"key\"": {
                    "\"key\"": 99
                }
            }
        ]
    },
    "key": "top",
    "\"key\"": 42
}

Selector:

$.."key"

Dot Notation With Empty Path

Test Data:

{
    "key": 42,
    "": 9001,
    "''": "nice"
}

Selector:

$.

Dot Notation With Key Root Literal

Test Data:

{
    "$": "value"
}

Selector:

$.$

Dot Notation With Number

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$.2

Dot Notation With Number -1

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$.-1

Dot Notation With Single Quotes

Test Data:

{
    "key": "value",
    "'key'": 42
}

Selector:

$.'key'

Dot Notation With Single Quotes After Recursive Descent

Test Data:

{
    "object": {
        "key": "value",
        "'key'": 100,
        "array": [
            {
                "key": "something",
                "'key'": 0
            },
            {
                "key": {
                    "key": "russian dolls"
                },
                "'key'": {
                    "'key'": 99
                }
            }
        ]
    },
    "key": "top",
    "'key'": 42
}

Selector:

$..'key'

Dot Notation With Single Quotes And Dot

Test Data:

{
    "some.key": 42,
    "some": {
        "key": "value"
    },
    "'some.key'": 43
}

Selector:

$.'some.key'

Dot Notation Without Root

Test Data:

{
    "key": "value"
}

Selector:

key
Filter Expression
Table of Contents

Filter Expression After Dot Notation With Wildcard After Recursive Descent

Test Data:

[
    {
        "complext": {
            "one": [
                {
                    "name": "first",
                    "id": 1
                },
                {
                    "name": "next",
                    "id": 2
                },
                {
                    "name": "another",
                    "id": 3
                },
                {
                    "name": "more",
                    "id": 4
                }
            ],
            "more": {
                "name": "next to last",
                "id": 5
            }
        }
    },
    {
        "name": "last",
        "id": 6
    }
]

Selector:

$..*[?(@.id>2)]

Filter Expression After Recursive Descent

Test Data:

{
    "id": 2,
    "more": [
        {
            "id": 2
        },
        {
            "more": {
                "id": 2
            }
        },
        {
            "id": {
                "id": 2
            }
        },
        [
            {
                "id": 2
            }
        ]
    ]
}

Selector:

$..[?(@.id==2)]

Filter Expression On Object

Test Data:

{
    "key": 42,
    "another": {
        "key": 1
    }
}

Selector:

$[?(@.key)]

Filter Expression With Addition

Test Data:

[
    {
        "key": 60
    },
    {
        "key": 50
    },
    {
        "key": 10
    },
    {
        "key": -50
    },
    {
        "key+50": 100
    }
]

Selector:

$[?(@.key+50==100)]

Filter Expression With Boolean And Operator

Test Data:

[
    {
        "key": 42
    },
    {
        "key": 43
    },
    {
        "key": 44
    }
]

Selector:

$[?(@.key>42 && @.key<44)]

Filter Expression With Boolean And Operator And Value False

Test Data:

[
    {
        "key": 1
    },
    {
        "key": 3
    },
    {
        "key": "nice"
    },
    {
        "key": true
    },
    {
        "key": null
    },
    {
        "key": false
    },
    {
        "key": {}
    },
    {
        "key": []
    },
    {
        "key": -1
    },
    {
        "key": 0
    },
    {
        "key": ""
    }
]

Selector:

$[?(@.key>0 && false)]

Filter Expression With Boolean And Operator And Value True

Test Data:

[
    {
        "key": 1
    },
    {
        "key": 3
    },
    {
        "key": "nice"
    },
    {
        "key": true
    },
    {
        "key": null
    },
    {
        "key": false
    },
    {
        "key": {}
    },
    {
        "key": []
    },
    {
        "key": -1
    },
    {
        "key": 0
    },
    {
        "key": ""
    }
]

Selector:

$[?(@.key>0 && true)]

Filter Expression With Boolean Or Operator

Test Data:

[
    {
        "key": 42
    },
    {
        "key": 43
    },
    {
        "key": 44
    }
]

Selector:

$[?(@.key>43 || @.key<43)]

Filter Expression With Boolean Or Operator And Value False

Test Data:

[
    {
        "key": 1
    },
    {
        "key": 3
    },
    {
        "key": "nice"
    },
    {
        "key": true
    },
    {
        "key": null
    },
    {
        "key": false
    },
    {
        "key": {}
    },
    {
        "key": []
    },
    {
        "key": -1
    },
    {
        "key": 0
    },
    {
        "key": ""
    }
]

Selector:

$[?(@.key>0 || false)]

Filter Expression With Boolean Or Operator And Value True

Test Data:

[
    {
        "key": 1
    },
    {
        "key": 3
    },
    {
        "key": "nice"
    },
    {
        "key": true
    },
    {
        "key": null
    },
    {
        "key": false
    },
    {
        "key": {}
    },
    {
        "key": []
    },
    {
        "key": -1
    },
    {
        "key": 0
    },
    {
        "key": ""
    }
]

Selector:

$[?(@.key>0 || true)]

Filter Expression With Bracket Notation With -1

Test Data:

[
    [
        2,
        3
    ],
    [
        "a"
    ],
    [
        0,
        2
    ],
    [
        2
    ]
]

Selector:

$[?(@[-1]==2)]

Filter Expression With Bracket Notation With Number On Object

Test Data:

{
    "1": [
        "a",
        "b"
    ],
    "2": [
        "x",
        "y"
    ]
}

Selector:

$[?(@[1]=='b')]

Filter Expression With Current Object

Test Data:

[
    "some value",
    null,
    "value",
    0,
    1,
    -1,
    "",
    [],
    {},
    false,
    true
]

Selector:

$[?(@)]

Filter Expression With Different Grouped Operators

Test Data:

[
    {
        "a": true
    },
    {
        "a": true,
        "b": true
    },
    {
        "a": true,
        "b": true,
        "c": true
    },
    {
        "b": true,
        "c": true
    },
    {
        "a": true,
        "c": true
    },
    {
        "c": true
    },
    {
        "b": true
    }
]

Selector:

$[?(@.a && (@.b || @.c))]

Filter Expression With Different Ungrouped Operators

Test Data:

[
    {
        "a": true,
        "b": true
    },
    {
        "a": true,
        "b": true,
        "c": true
    },
    {
        "b": true,
        "c": true
    },
    {
        "a": true,
        "c": true
    },
    {
        "a": true
    },
    {
        "b": true
    },
    {
        "c": true
    },
    {
        "d": true
    },
    {}
]

Selector:

$[?(@.a && @.b || @.c)]

Filter Expression With Division

Test Data:

[
    {
        "key": 60
    },
    {
        "key": 50
    },
    {
        "key": 10
    },
    {
        "key": -50
    },
    {
        "key\/10": 5
    }
]

Selector:

$[?(@.key/10==5)]

Filter Expression With Empty Expression

Test Data:

[
    1,
    {
        "key": 42
    },
    "value",
    null
]

Selector:

$[?()]

Filter Expression With Equals

Test Data:

[
    {
        "key": 0
    },
    {
        "key": 42
    },
    {
        "key": -1
    },
    {
        "key": 1
    },
    {
        "key": 41
    },
    {
        "key": 43
    },
    {
        "key": 42.0001
    },
    {
        "key": 41.9999
    },
    {
        "key": 100
    },
    {
        "key": "some"
    },
    {
        "key": "42"
    },
    {
        "key": null
    },
    {
        "key": 420
    },
    {
        "key": ""
    },
    {
        "key": {}
    },
    {
        "key": []
    },
    {
        "key": [
            42
        ]
    },
    {
        "key": {
            "key": 42
        }
    },
    {
        "key": {
            "some": 42
        }
    },
    {
        "some": "value"
    }
]

Selector:

$[?(@.key==42)]

Filter Expression With Equals Array

Test Data:

[
    {
        "d": [
            "v1",
            "v2"
        ]
    },
    {
        "d": [
            "a",
            "b"
        ]
    },
    {
        "d": "v1"
    },
    {
        "d": "v2"
    },
    {
        "d": {}
    },
    {
        "d": []
    },
    {
        "d": null
    },
    {
        "d": -1
    },
    {
        "d": 0
    },
    {
        "d": 1
    },
    {
        "d": "['v1','v2']"
    },
    {
        "d": "['v1', 'v2']"
    },
    {
        "d": "v1,v2"
    },
    {
        "d": "[\"v1\", \"v2\"]"
    },
    {
        "d": "[\"v1\",\"v2\"]"
    }
]

Selector:

$[?(@.d==["v1","v2"])]

Filter Expression With Equals Array For Array Slice With Range 1

Test Data:

[
    [
        1,
        2,
        3
    ],
    [
        1
    ],
    [
        2,
        3
    ],
    1,
    2
]

Selector:

$[?(@[0:1]==[1])]

Filter Expression With Equals Array For Dot Notation With Star

Test Data:

[
    [
        1,
        2
    ],
    [
        2,
        3
    ],
    [
        1
    ],
    [
        2
    ],
    [
        1,
        2,
        3
    ],
    1,
    2,
    3
]

Selector:

$[?(@.*==[1,2])]

Filter Expression With Equals Array With Single Quotes

Test Data:

[
    {
        "d": [
            "v1",
            "v2"
        ]
    },
    {
        "d": [
            "a",
            "b"
        ]
    },
    {
        "d": "v1"
    },
    {
        "d": "v2"
    },
    {
        "d": {}
    },
    {
        "d": []
    },
    {
        "d": null
    },
    {
        "d": -1
    },
    {
        "d": 0
    },
    {
        "d": 1
    },
    {
        "d": "['v1','v2']"
    },
    {
        "d": "['v1', 'v2']"
    },
    {
        "d": "v1,v2"
    },
    {
        "d": "[\"v1\", \"v2\"]"
    },
    {
        "d": "[\"v1\",\"v2\"]"
    }
]

Selector:

$[?(@.d==['v1','v2'])]

Filter Expression With Equals Boolean Expression Value

Test Data:

[
    {
        "key": 42
    },
    {
        "key": 43
    },
    {
        "key": 44
    }
]

Selector:

$[?((@.key<44)==false)]

Filter Expression With Equals False

Test Data:

[
    {
        "some": "some value"
    },
    {
        "key": true
    },
    {
        "key": false
    },
    {
        "key": null
    },
    {
        "key": "value"
    },
    {
        "key": ""
    },
    {
        "key": 0
    },
    {
        "key": 1
    },
    {
        "key": -1
    },
    {
        "key": 42
    },
    {
        "key": {}
    },
    {
        "key": []
    }
]

Selector:

$[?(@.key==false)]

Filter Expression With Equals Null

Test Data:

[
    {
        "some": "some value"
    },
    {
        "key": true
    },
    {
        "key": false
    },
    {
        "key": null
    },
    {
        "key": "value"
    },
    {
        "key": ""
    },
    {
        "key": 0
    },
    {
        "key": 1
    },
    {
        "key": -1
    },
    {
        "key": 42
    },
    {
        "key": {}
    },
    {
        "key": []
    }
]

Selector:

$[?(@.key==null)]

Filter Expression With Equals Number For Array Slice With Range 1

Test Data:

[
    [
        1,
        2,
        3
    ],
    [
        1
    ],
    [
        2,
        3
    ],
    1,
    2
]

Selector:

$[?(@[0:1]==1)]

Filter Expression With Equals Number For Bracket Notation With Star

Test Data:

[
    [
        1,
        2
    ],
    [
        2,
        3
    ],
    [
        1
    ],
    [
        2
    ],
    [
        1,
        2,
        3
    ],
    1,
    2,
    3
]

Selector:

$[?(@[*]==2)]

Filter Expression With Equals Number For Dot Notation With Star

Test Data:

[
    [
        1,
        2
    ],
    [
        2,
        3
    ],
    [
        1
    ],
    [
        2
    ],
    [
        1,
        2,
        3
    ],
    1,
    2,
    3
]

Selector:

$[?(@.*==2)]

Filter Expression With Equals Number With Fraction

Test Data:

[
    {
        "key": -12.3
    },
    {
        "key": -0.123
    },
    {
        "key": -12
    },
    {
        "key": 12.3
    },
    {
        "key": 2
    },
    {
        "key": "-0.123e2"
    }
]

Selector:

$[?(@.key==-0.123e2)]

Filter Expression With Equals Number With Leading Zeros

Test Data:

[
    {
        "key": "010"
    },
    {
        "key": "10"
    },
    {
        "key": 10
    },
    {
        "key": 0
    },
    {
        "key": 8
    }
]

Selector:

$[?(@.key==010)]

Filter Expression With Equals Object

Test Data:

[
    {
        "d": {
            "k": "v"
        }
    },
    {
        "d": {
            "a": "b"
        }
    },
    {
        "d": "k"
    },
    {
        "d": "v"
    },
    {
        "d": {}
    },
    {
        "d": []
    },
    {
        "d": null
    },
    {
        "d": -1
    },
    {
        "d": 0
    },
    {
        "d": 1
    },
    {
        "d": "[object Object]"
    },
    {
        "d": "{\"k\": \"v\"}"
    },
    {
        "d": "{\"k\":\"v\"}"
    },
    "v"
]

Selector:

$[?(@.d=={"k":"v"})]

Filter Expression With Equals On Array Of Numbers

Test Data:

[
    0,
    42,
    -1,
    41,
    43,
    42.0001,
    41.9999,
    null,
    100
]

Selector:

$[?(@==42)]

Filter Expression With Equals On Object

Test Data:

{
    "a": {
        "key": 0
    },
    "b": {
        "key": 42
    },
    "c": {
        "key": -1
    },
    "d": {
        "key": 41
    },
    "e": {
        "key": 43
    },
    "f": {
        "key": 42.0001
    },
    "g": {
        "key": 41.9999
    },
    "h": {
        "key": 100
    },
    "i": {
        "some": "value"
    }
}

Selector:

$[?(@.key==42)]

Filter Expression With Equals On Object With Key Matching Query

Test Data:

{
    "id": 2
}

Selector:

$[?(@.id==2)]

Filter Expression With Equals String

Test Data:

[
    {
        "key": "some"
    },
    {
        "key": "value"
    },
    {
        "key": null
    },
    {
        "key": 0
    },
    {
        "key": 1
    },
    {
        "key": -1
    },
    {
        "key": ""
    },
    {
        "key": {}
    },
    {
        "key": []
    },
    {
        "key": "valuemore"
    },
    {
        "key": "morevalue"
    },
    {
        "key": [
            "value"
        ]
    },
    {
        "key": {
            "some": "value"
        }
    },
    {
        "key": {
            "key": "value"
        }
    },
    {
        "some": "value"
    }
]

Selector:

$[?(@.key=="value")]

Filter Expression With Equals True

Test Data:

[
    {
        "some": "some value"
    },
    {
        "key": true
    },
    {
        "key": false
    },
    {
        "key": null
    },
    {
        "key": "value"
    },
    {
        "key": ""
    },
    {
        "key": 0
    },
    {
        "key": 1
    },
    {
        "key": -1
    },
    {
        "key": 42
    },
    {
        "key": {}
    },
    {
        "key": []
    }
]

Selector:

$[?(@.key==true)]

Filter Expression With Equals With Root Reference

Test Data:

{
    "value": 42,
    "items": [
        {
            "key": 10
        },
        {
            "key": 42
        },
        {
            "key": 50
        }
    ]
}

Selector:

$.items[?(@.key==$.value)]

Filter Expression With Greater Than

Test Data:

[
    {
        "key": 0
    },
    {
        "key": 42
    },
    {
        "key": -1
    },
    {
        "key": 41
    },
    {
        "key": 43
    },
    {
        "key": 42.0001
    },
    {
        "key": 41.9999
    },
    {
        "key": 100
    },
    {
        "key": "43"
    },
    {
        "key": "42"
    },
    {
        "key": "41"
    },
    {
        "key": "value"
    },
    {
        "some": "value"
    }
]

Selector:

$[?(@.key>42)]

Filter Expression With Greater Than Or Equal

Test Data:

[
    {
        "key": 0
    },
    {
        "key": 42
    },
    {
        "key": -1
    },
    {
        "key": 41
    },
    {
        "key": 43
    },
    {
        "key": 42.0001
    },
    {
        "key": 41.9999
    },
    {
        "key": 100
    },
    {
        "key": "43"
    },
    {
        "key": "42"
    },
    {
        "key": "41"
    },
    {
        "key": "value"
    },
    {
        "some": "value"
    }
]

Selector:

$[?(@.key>=42)]

Filter Expression With In Array Of Values

Test Data:

[
    {
        "d": 1
    },
    {
        "d": 2
    },
    {
        "d": 1
    },
    {
        "d": 3
    },
    {
        "d": 4
    }
]

Selector:

$[?(@.d in [2, 3])]

Filter Expression With In Current Object

Test Data:

[
    {
        "d": [
            1,
            2,
            3
        ]
    },
    {
        "d": [
            2
        ]
    },
    {
        "d": [
            1
        ]
    },
    {
        "d": [
            3,
            4
        ]
    },
    {
        "d": [
            4,
            2
        ]
    }
]

Selector:

$[?(2 in @.d)]

Filter Expression With Less Than

Test Data:

[
    {
        "key": 0
    },
    {
        "key": 42
    },
    {
        "key": -1
    },
    {
        "key": 41
    },
    {
        "key": 43
    },
    {
        "key": 42.0001
    },
    {
        "key": 41.9999
    },
    {
        "key": 100
    },
    {
        "key": "43"
    },
    {
        "key": "42"
    },
    {
        "key": "41"
    },
    {
        "key": "value"
    },
    {
        "some": "value"
    }
]

Selector:

$[?(@.key<42)]

Filter Expression With Less Than Or Equal

Test Data:

[
    {
        "key": 0
    },
    {
        "key": 42
    },
    {
        "key": -1
    },
    {
        "key": 41
    },
    {
        "key": 43
    },
    {
        "key": 42.0001
    },
    {
        "key": 41.9999
    },
    {
        "key": 100
    },
    {
        "key": "43"
    },
    {
        "key": "42"
    },
    {
        "key": "41"
    },
    {
        "key": "value"
    },
    {
        "some": "value"
    }
]

Selector:

$[?(@.key<=42)]

Filter Expression With Multiplication

Test Data:

[
    {
        "key": 60
    },
    {
        "key": 50
    },
    {
        "key": 10
    },
    {
        "key": -50
    },
    {
        "key*2": 100
    }
]

Selector:

$[?(@.key*2==100)]

Filter Expression With Negation And Equals

Test Data:

[
    {
        "key": 0
    },
    {
        "key": 42
    },
    {
        "key": -1
    },
    {
        "key": 41
    },
    {
        "key": 43
    },
    {
        "key": 42.0001
    },
    {
        "key": 41.9999
    },
    {
        "key": 100
    },
    {
        "key": "43"
    },
    {
        "key": "42"
    },
    {
        "key": "41"
    },
    {
        "key": "value"
    },
    {
        "some": "value"
    }
]

Selector:

$[?(!(@.key==42))]

Filter Expression With Negation And Less Than

Test Data:

[
    {
        "key": 0
    },
    {
        "key": 42
    },
    {
        "key": -1
    },
    {
        "key": 41
    },
    {
        "key": 43
    },
    {
        "key": 42.0001
    },
    {
        "key": 41.9999
    },
    {
        "key": 100
    },
    {
        "key": "43"
    },
    {
        "key": "42"
    },
    {
        "key": "41"
    },
    {
        "key": "value"
    },
    {
        "some": "value"
    }
]

Selector:

$[?(!(@.key<42))]

Filter Expression With Not Equals

Test Data:

[
    {
        "key": 0
    },
    {
        "key": 42
    },
    {
        "key": -1
    },
    {
        "key": 1
    },
    {
        "key": 41
    },
    {
        "key": 43
    },
    {
        "key": 42.0001
    },
    {
        "key": 41.9999
    },
    {
        "key": 100
    },
    {
        "key": "some"
    },
    {
        "key": "42"
    },
    {
        "key": null
    },
    {
        "key": 420
    },
    {
        "key": ""
    },
    {
        "key": {}
    },
    {
        "key": []
    },
    {
        "key": [
            42
        ]
    },
    {
        "key": {
            "key": 42
        }
    },
    {
        "key": {
            "some": 42
        }
    },
    {
        "some": "value"
    }
]

Selector:

$[?(@.key!=42)]

Filter Expression With Regular Expression

Test Data:

[
    {
        "name": "hullo world"
    },
    {
        "name": "hello world"
    },
    {
        "name": "yes hello world"
    },
    {
        "name": "HELLO WORLD"
    },
    {
        "name": "good bye"
    }
]

Selector:

$[?(@.name=~/hello.*/)]

Filter Expression With Set Wise Comparison To Scalar

Test Data:

[
    [
        1,
        2
    ],
    [
        3,
        4
    ],
    [
        5,
        6
    ]
]

Selector:

$[?(@[*]>=4)]

Filter Expression With Set Wise Comparison To Set

Test Data:

{
    "x": [
        [
            1,
            2
        ],
        [
            3,
            4
        ],
        [
            5,
            6
        ]
    ],
    "y": [
        3,
        4,
        5
    ]
}

Selector:

$.x[?(@[*]>=$.y[*])]

Filter Expression With Single Equal

Test Data:

[
    {
        "key": 0
    },
    {
        "key": 42
    },
    {
        "key": -1
    },
    {
        "key": 1
    },
    {
        "key": 41
    },
    {
        "key": 43
    },
    {
        "key": 42.0001
    },
    {
        "key": 41.9999
    },
    {
        "key": 100
    },
    {
        "key": "some"
    },
    {
        "key": "42"
    },
    {
        "key": null
    },
    {
        "key": 420
    },
    {
        "key": ""
    },
    {
        "key": {}
    },
    {
        "key": []
    },
    {
        "key": [
            42
        ]
    },
    {
        "key": {
            "key": 42
        }
    },
    {
        "key": {
            "some": 42
        }
    },
    {
        "some": "value"
    }
]

Selector:

$[?(@.key=42)]

Filter Expression With Subfilter

Test Data:

[
    {
        "a": [
            {
                "price": 1
            },
            {
                "price": 3
            }
        ]
    },
    {
        "a": [
            {
                "price": 11
            }
        ]
    },
    {
        "a": [
            {
                "price": 8
            },
            {
                "price": 12
            },
            {
                "price": 3
            }
        ]
    },
    {
        "a": []
    }
]

Selector:

$[?(@.a[?(@.price>10)])]

Filter Expression With Subtraction

Test Data:

[
    {
        "key": 60
    },
    {
        "key": 50
    },
    {
        "key": 10
    },
    {
        "key": -50
    },
    {
        "key-50": -100
    }
]

Selector:

$[?(@.key-50==-100)]

Filter Expression With Tautological Comparison

Test Data:

[
    1,
    3,
    "nice",
    true,
    null,
    false,
    {},
    [],
    -1,
    0,
    ""
]

Selector:

$[?(1==1)]

Filter Expression With Triple Equal

Test Data:

[
    {
        "key": 0
    },
    {
        "key": 42
    },
    {
        "key": -1
    },
    {
        "key": 1
    },
    {
        "key": 41
    },
    {
        "key": 43
    },
    {
        "key": 42.0001
    },
    {
        "key": 41.9999
    },
    {
        "key": 100
    },
    {
        "key": "some"
    },
    {
        "key": "42"
    },
    {
        "key": null
    },
    {
        "key": 420
    },
    {
        "key": ""
    },
    {
        "key": {}
    },
    {
        "key": []
    },
    {
        "key": [
            42
        ]
    },
    {
        "key": {
            "key": 42
        }
    },
    {
        "key": {
            "some": 42
        }
    },
    {
        "some": "value"
    }
]

Selector:

$[?(@.key===42)]

Filter Expression With Value

Test Data:

[
    {
        "some": "some value"
    },
    {
        "key": true
    },
    {
        "key": false
    },
    {
        "key": null
    },
    {
        "key": "value"
    },
    {
        "key": ""
    },
    {
        "key": 0
    },
    {
        "key": 1
    },
    {
        "key": -1
    },
    {
        "key": 42
    },
    {
        "key": {}
    },
    {
        "key": []
    }
]

Selector:

$[?(@.key)]

Filter Expression With Value After Dot Notation With Wildcard On Array Of Objects

Test Data:

[
    {
        "some": "some value"
    },
    {
        "key": "value"
    }
]

Selector:

$.*[?(@.key)]

Filter Expression With Value After Recursive Descent

Test Data:

{
    "id": 2,
    "more": [
        {
            "id": 2
        },
        {
            "more": {
                "id": 2
            }
        },
        {
            "id": {
                "id": 2
            }
        },
        [
            {
                "id": 2
            }
        ]
    ]
}

Selector:

$..[?(@.id)]

Filter Expression With Value False

Test Data:

[
    1,
    3,
    "nice",
    true,
    null,
    false,
    {},
    [],
    -1,
    0,
    ""
]

Selector:

$[?(false)]

Filter Expression With Value From Recursive Descent

Test Data:

[
    {
        "key": [
            {
                "child": 1
            },
            {
                "child": 2
            }
        ]
    },
    {
        "key": [
            {
                "child": 2
            }
        ]
    },
    {
        "key": [
            {}
        ]
    },
    {
        "key": [
            {
                "something": 42
            }
        ]
    },
    {}
]

Selector:

$[?(@..child)]

Filter Expression With Value Null

Test Data:

[
    1,
    3,
    "nice",
    true,
    null,
    false,
    {},
    [],
    -1,
    0,
    ""
]

Selector:

$[?(null)]

Filter Expression With Value True

Test Data:

[
    1,
    3,
    "nice",
    true,
    null,
    false,
    {},
    [],
    -1,
    0,
    ""
]

Selector:

$[?(true)]

Filter Expression Without Parens

Test Data:

[
    {
        "key": 0
    },
    {
        "key": 42
    },
    {
        "key": -1
    },
    {
        "key": 1
    },
    {
        "key": 41
    },
    {
        "key": 43
    },
    {
        "key": 42.0001
    },
    {
        "key": 41.9999
    },
    {
        "key": 100
    },
    {
        "key": "some"
    },
    {
        "key": "42"
    },
    {
        "key": null
    },
    {
        "key": 420
    },
    {
        "key": ""
    },
    {
        "key": {}
    },
    {
        "key": []
    },
    {
        "key": [
            42
        ]
    },
    {
        "key": {
            "key": 42
        }
    },
    {
        "key": {
            "some": 42
        }
    },
    {
        "some": "value"
    }
]

Selector:

Filter Expression Without Value

Test Data:

[
    {
        "some": "some value"
    },
    {
        "key": true
    },
    {
        "key": false
    },
    {
        "key": null
    },
    {
        "key": "value"
    },
    {
        "key": ""
    },
    {
        "key": 0
    },
    {
        "key": 1
    },
    {
        "key": -1
    },
    {
        "key": 42
    },
    {
        "key": {}
    },
    {
        "key": []
    }
]

Selector:

Parens Notation
Table of Contents

Parens Notation

Test Data:

{
    "key": 1,
    "some": 2,
    "more": 3
}

Selector:

$(key,more)
Recursive Descent
Table of Contents

Recursive Descent

Test Data:

[
    {
        "a": {
            "b": "c"
        }
    },
    [
        0,
        1
    ]
]

Selector:

$..

Recursive Descent After Dot Notation

Test Data:

{
    "some key": "value",
    "key": {
        "complex": "string",
        "primitives": [
            0,
            1
        ]
    }
}

Selector:

$.key..
Script Expression
Table of Contents

Script Expression

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[(@.length-1)]
Union
Table of Contents

Union With Filter

Test Data:

[
    {
        "key": 1
    },
    {
        "key": 8
    },
    {
        "key": 3
    },
    {
        "key": 10
    },
    {
        "key": 7
    },
    {
        "key": 2
    },
    {
        "key": 6
    },
    {
        "key": 4
    }
]

Selector:

$[?(@.key<3),?(@.key>6)]

Union With Keys After Dot Notation With Wildcard

Test Data:

[
    {
        "c": "cc1",
        "d": "dd1",
        "e": "ee1"
    },
    {
        "c": "cc2",
        "d": "dd2",
        "e": "ee2"
    }
]

Selector:

$.*['c','d']

Union With Keys After Recursive Descent

Test Data:

[
    {
        "c": "cc1",
        "d": "dd1",
        "e": "ee1"
    },
    {
        "c": "cc2",
        "child": {
            "d": "dd2"
        }
    },
    {
        "c": "cc3"
    },
    {
        "d": "dd4"
    },
    {
        "child": {
            "c": "cc5"
        }
    }
]

Selector:

$..['c','d']

Union With Repeated Matches After Dot Notation With Wildcard

Test Data:

{
    "a": [
        "string",
        null,
        true
    ],
    "b": [
        false,
        "string",
        5.4
    ]
}

Selector:

$.*[0,:5]

Union With Slice And Number

Test Data:

[
    1,
    2,
    3,
    4,
    5
]

Selector:

$[1:3,4]

Union With Wildcard And Number

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[*,1]

Problematic queries

The following queries are considered problematic, because they may crash the PHP process, thus they shouldn't be executed.

Array Slice
Table of Contents

Array Slice With Large Number For Start

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[-113667776004:2]

Array Slice With Negative Step And Start Greater Than End

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[0:3:-2]

Array Slice With Negative Step Only

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[::-2]

Array Slice With Open End And Negative Step

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[3::-1]

Array Slice With Open Start And Negative Step

Test Data:

[
    "first",
    "second",
    "third",
    "forth",
    "fifth"
]

Selector:

$[:2:-1]
Clone this wiki locally