[
    {
        "cases": [
            {
                "expression": "foo.{bar: bar}",
                "is_deeply": 1,
                "result": {
                    "bar": "bar"
                }
            },
            {
                "expression": "foo.{\"bar\": bar}",
                "is_deeply": 1,
                "result": {
                    "bar": "bar"
                }
            },
            {
                "expression": "foo.{\"foo.bar\": bar}",
                "is_deeply": 1,
                "result": {
                    "foo.bar": "bar"
                }
            },
            {
                "expression": "foo.{bar: bar, baz: baz}",
                "is_deeply": 1,
                "result": {
                    "bar": "bar",
                    "baz": "baz"
                }
            },
            {
                "expression": "foo.{\"bar\": bar, \"baz\": baz}",
                "is_deeply": 1,
                "result": {
                    "bar": "bar",
                    "baz": "baz"
                }
            },
            {
                "expression": "{\"baz\": baz, \"qux\\\"\": \"qux\\\"\"}",
                "is_deeply": 1,
                "result": {
                    "baz": 2,
                    "qux\"": 3
                }
            },
            {
                "expression": "foo.{bar:bar,baz:baz}",
                "is_deeply": 1,
                "result": {
                    "bar": "bar",
                    "baz": "baz"
                }
            },
            {
                "expression": "foo.{bar: bar,qux: qux}",
                "is_deeply": 1,
                "result": {
                    "bar": "bar",
                    "qux": "qux"
                }
            },
            {
                "expression": "foo.{bar: bar, noexist: noexist}",
                "is_deeply": 1,
                "result": {
                    "bar": "bar",
                    "noexist": null
                }
            },
            {
                "expression": "foo.{noexist: noexist, alsonoexist: alsonoexist}",
                "is_deeply": 1,
                "result": {
                    "alsonoexist": null,
                    "noexist": null
                }
            },
            {
                "expression": "foo.badkey.{nokey: nokey, alsonokey: alsonokey}",
                "result": null
            },
            {
                "expression": "foo.nested.*.{a: a,b: b}",
                "is_deeply": 1,
                "result": [
                    {
                        "a": "first",
                        "b": "second"
                    },
                    {
                        "a": "first",
                        "b": "second"
                    },
                    {
                        "a": "first",
                        "b": "second"
                    }
                ]
            },
            {
                "expression": "foo.nested.three.{a: a, cinner: c.inner}",
                "is_deeply": 1,
                "result": {
                    "a": "first",
                    "cinner": "third"
                }
            },
            {
                "expression": "foo.nested.three.{a: a, c: c.inner.bad.key}",
                "is_deeply": 1,
                "result": {
                    "a": "first",
                    "c": null
                }
            },
            {
                "expression": "foo.{a: nested.one.a, b: nested.two.b}",
                "is_deeply": 1,
                "result": {
                    "a": "first",
                    "b": "second"
                }
            },
            {
                "expression": "{bar: bar, baz: baz}",
                "is_deeply": 1,
                "result": {
                    "bar": 1,
                    "baz": 2
                }
            },
            {
                "expression": "{bar: bar}",
                "is_deeply": 1,
                "result": {
                    "bar": 1
                }
            },
            {
                "expression": "{otherkey: bar}",
                "is_deeply": 1,
                "result": {
                    "otherkey": 1
                }
            },
            {
                "expression": "{no: no, exist: exist}",
                "is_deeply": 1,
                "result": {
                    "exist": null,
                    "no": null
                }
            },
            {
                "expression": "foo.[bar]",
                "is_deeply": 1,
                "result": [
                    "bar"
                ]
            },
            {
                "expression": "foo.[bar,baz]",
                "is_deeply": 1,
                "result": [
                    "bar",
                    "baz"
                ]
            },
            {
                "expression": "foo.[bar,qux]",
                "is_deeply": 1,
                "result": [
                    "bar",
                    "qux"
                ]
            },
            {
                "expression": "foo.[bar,noexist]",
                "is_deeply": 1,
                "result": [
                    "bar",
                    null
                ]
            },
            {
                "expression": "foo.[noexist,alsonoexist]",
                "is_deeply": 1,
                "result": [
                    null,
                    null
                ]
            }
        ],
        "given": {
            "bar": 1,
            "baz": 2,
            "foo": {
                "bar": "bar",
                "baz": "baz",
                "nested": {
                    "one": {
                        "a": "first",
                        "b": "second",
                        "c": "third"
                    },
                    "three": {
                        "a": "first",
                        "b": "second",
                        "c": {
                            "inner": "third"
                        }
                    },
                    "two": {
                        "a": "first",
                        "b": "second",
                        "c": "third"
                    }
                },
                "qux": "qux"
            },
            "qux\"": 3
        }
    },
    {
        "cases": [
            {
                "expression": "foo.{bar:bar,baz:baz}",
                "is_deeply": 1,
                "result": {
                    "bar": 1,
                    "baz": [
                        2,
                        3,
                        4
                    ]
                }
            },
            {
                "expression": "foo.[bar,baz[0]]",
                "is_deeply": 1,
                "result": [
                    1,
                    2
                ]
            },
            {
                "expression": "foo.[bar,baz[1]]",
                "is_deeply": 1,
                "result": [
                    1,
                    3
                ]
            },
            {
                "expression": "foo.[bar,baz[2]]",
                "is_deeply": 1,
                "result": [
                    1,
                    4
                ]
            },
            {
                "expression": "foo.[bar,baz[3]]",
                "is_deeply": 1,
                "result": [
                    1,
                    null
                ]
            },
            {
                "expression": "foo.[bar[0],baz[3]]",
                "is_deeply": 1,
                "result": [
                    null,
                    null
                ]
            }
        ],
        "given": {
            "foo": {
                "bar": 1,
                "baz": [
                    2,
                    3,
                    4
                ]
            }
        }
    },
    {
        "cases": [
            {
                "expression": "foo.{bar: bar, baz: baz}",
                "is_deeply": 1,
                "result": {
                    "bar": 1,
                    "baz": 2
                }
            },
            {
                "expression": "foo.[bar,baz]",
                "is_deeply": 1,
                "result": [
                    1,
                    2
                ]
            }
        ],
        "given": {
            "foo": {
                "bar": 1,
                "baz": 2
            }
        }
    },
    {
        "cases": [
            {
                "expression": "foo.{bar: bar.baz[1],includeme: includeme}",
                "is_deeply": 1,
                "result": {
                    "bar": {
                        "common": "second",
                        "two": 2
                    },
                    "includeme": true
                }
            },
            {
                "expression": "foo.{\"bar.baz.two\": bar.baz[1].two, includeme: includeme}",
                "is_deeply": 1,
                "result": {
                    "bar.baz.two": 2,
                    "includeme": true
                }
            },
            {
                "expression": "foo.[includeme, bar.baz[*].common]",
                "is_deeply": 1,
                "result": [
                    true,
                    [
                        "first",
                        "second"
                    ]
                ]
            },
            {
                "expression": "foo.[includeme, bar.baz[*].none]",
                "is_deeply": 1,
                "result": [
                    true,
                    []
                ]
            },
            {
                "expression": "foo.[includeme, bar.baz[].common]",
                "is_deeply": 1,
                "result": [
                    true,
                    [
                        "first",
                        "second"
                    ]
                ]
            }
        ],
        "given": {
            "foo": {
                "bar": {
                    "baz": [
                        {
                            "common": "first",
                            "one": 1
                        },
                        {
                            "common": "second",
                            "two": 2
                        }
                    ]
                },
                "ignoreme": 1,
                "includeme": true
            }
        }
    },
    {
        "cases": [
            {
                "expression": "reservations[*].instances[*].{id: id, name: name}",
                "is_deeply": 1,
                "result": [
                    [
                        {
                            "id": "id1",
                            "name": "first"
                        },
                        {
                            "id": "id2",
                            "name": "second"
                        }
                    ],
                    [
                        {
                            "id": "id3",
                            "name": "third"
                        },
                        {
                            "id": "id4",
                            "name": "fourth"
                        }
                    ]
                ]
            },
            {
                "expression": "reservations[].instances[].{id: id, name: name}",
                "is_deeply": 1,
                "result": [
                    {
                        "id": "id1",
                        "name": "first"
                    },
                    {
                        "id": "id2",
                        "name": "second"
                    },
                    {
                        "id": "id3",
                        "name": "third"
                    },
                    {
                        "id": "id4",
                        "name": "fourth"
                    }
                ]
            },
            {
                "expression": "reservations[].instances[].[id, name]",
                "is_deeply": 1,
                "result": [
                    [
                        "id1",
                        "first"
                    ],
                    [
                        "id2",
                        "second"
                    ],
                    [
                        "id3",
                        "third"
                    ],
                    [
                        "id4",
                        "fourth"
                    ]
                ]
            }
        ],
        "given": {
            "reservations": [
                {
                    "instances": [
                        {
                            "id": "id1",
                            "name": "first"
                        },
                        {
                            "id": "id2",
                            "name": "second"
                        }
                    ]
                },
                {
                    "instances": [
                        {
                            "id": "id3",
                            "name": "third"
                        },
                        {
                            "id": "id4",
                            "name": "fourth"
                        }
                    ]
                }
            ]
        }
    },
    {
        "cases": [
            {
                "expression": "foo",
                "is_deeply": 1,
                "result": [
                    {
                        "bar": [
                            {
                                "baz": 1,
                                "qux": 2
                            },
                            {
                                "baz": 3,
                                "qux": 4
                            }
                        ]
                    },
                    {
                        "bar": [
                            {
                                "baz": 5,
                                "qux": 6
                            },
                            {
                                "baz": 7,
                                "qux": 8
                            }
                        ]
                    }
                ]
            },
            {
                "expression": "foo[]",
                "is_deeply": 1,
                "result": [
                    {
                        "bar": [
                            {
                                "baz": 1,
                                "qux": 2
                            },
                            {
                                "baz": 3,
                                "qux": 4
                            }
                        ]
                    },
                    {
                        "bar": [
                            {
                                "baz": 5,
                                "qux": 6
                            },
                            {
                                "baz": 7,
                                "qux": 8
                            }
                        ]
                    }
                ]
            },
            {
                "expression": "foo[].bar",
                "is_deeply": 1,
                "result": [
                    [
                        {
                            "baz": 1,
                            "qux": 2
                        },
                        {
                            "baz": 3,
                            "qux": 4
                        }
                    ],
                    [
                        {
                            "baz": 5,
                            "qux": 6
                        },
                        {
                            "baz": 7,
                            "qux": 8
                        }
                    ]
                ]
            },
            {
                "expression": "foo[].bar[]",
                "is_deeply": 1,
                "result": [
                    {
                        "baz": 1,
                        "qux": 2
                    },
                    {
                        "baz": 3,
                        "qux": 4
                    },
                    {
                        "baz": 5,
                        "qux": 6
                    },
                    {
                        "baz": 7,
                        "qux": 8
                    }
                ]
            },
            {
                "expression": "foo[].bar[].[baz, qux]",
                "is_deeply": 1,
                "result": [
                    [
                        1,
                        2
                    ],
                    [
                        3,
                        4
                    ],
                    [
                        5,
                        6
                    ],
                    [
                        7,
                        8
                    ]
                ]
            },
            {
                "expression": "foo[].bar[].[baz]",
                "is_deeply": 1,
                "result": [
                    [
                        1
                    ],
                    [
                        3
                    ],
                    [
                        5
                    ],
                    [
                        7
                    ]
                ]
            },
            {
                "expression": "foo[].bar[].[baz, qux][]",
                "is_deeply": 1,
                "result": [
                    1,
                    2,
                    3,
                    4,
                    5,
                    6,
                    7,
                    8
                ]
            }
        ],
        "given": {
            "foo": [
                {
                    "bar": [
                        {
                            "baz": 1,
                            "qux": 2
                        },
                        {
                            "baz": 3,
                            "qux": 4
                        }
                    ]
                },
                {
                    "bar": [
                        {
                            "baz": 5,
                            "qux": 6
                        },
                        {
                            "baz": 7,
                            "qux": 8
                        }
                    ]
                }
            ]
        }
    },
    {
        "cases": [
            {
                "expression": "foo.[baz[*].bar, qux[0]]",
                "is_deeply": 1,
                "result": [
                    [
                        "abc",
                        "def"
                    ],
                    "zero"
                ]
            }
        ],
        "given": {
            "foo": {
                "baz": [
                    {
                        "bar": "abc"
                    },
                    {
                        "bar": "def"
                    }
                ],
                "qux": [
                    "zero"
                ]
            }
        }
    },
    {
        "cases": [
            {
                "expression": "foo.[baz[*].[bar, boo], qux[0]]",
                "is_deeply": 1,
                "result": [
                    [
                        [
                            "a",
                            "c"
                        ],
                        [
                            "d",
                            "f"
                        ]
                    ],
                    "zero"
                ]
            }
        ],
        "given": {
            "foo": {
                "baz": [
                    {
                        "bam": "b",
                        "bar": "a",
                        "boo": "c"
                    },
                    {
                        "bam": "e",
                        "bar": "d",
                        "boo": "f"
                    }
                ],
                "qux": [
                    "zero"
                ]
            }
        }
    },
    {
        "cases": [
            {
                "expression": "foo.[baz[*].not_there || baz[*].bar, qux[0]]",
                "is_deeply": 1,
                "result": [
                    [
                        "a",
                        "d"
                    ],
                    "zero"
                ]
            }
        ],
        "given": {
            "foo": {
                "baz": [
                    {
                        "bam": "b",
                        "bar": "a",
                        "boo": "c"
                    },
                    {
                        "bam": "e",
                        "bar": "d",
                        "boo": "f"
                    }
                ],
                "qux": [
                    "zero"
                ]
            }
        }
    },
    {
        "cases": [
            {
                "comment": "Nested multiselect",
                "expression": "[[*],*]",
                "is_deeply": 1,
                "result": [
                    null,
                    [
                        "object"
                    ]
                ]
            }
        ],
        "given": {
            "type": "object"
        }
    },
    {
        "cases": [
            {
                "comment": "Nested multiselect",
                "expression": "[[*]]",
                "is_deeply": 1,
                "result": [
                    []
                ]
            },
            {
                "comment": "Select on null",
                "expression": "missing.{foo: bar}",
                "result": null
            }
        ],
        "given": []
    }
]