{
  "tests": [
    {
      "name": "root",
      "selector": "$",
      "document": [
        "first",
        "second"
      ],
      "result": [
        [
          "first",
          "second"
        ]
      ],
      "result_paths": [
        "$"
      ]
    },
    {
      "name": "no leading whitespace",
      "selector": " $",
      "invalid_selector": true,
      "tags": [
        "whitespace"
      ]
    },
    {
      "name": "no trailing whitespace",
      "selector": "$ ",
      "invalid_selector": true,
      "tags": [
        "whitespace"
      ]
    },
    {
      "name": "name shorthand",
      "selector": "$.a",
      "document": {
        "a": "A",
        "b": "B"
      },
      "result": [
        "A"
      ],
      "result_paths": [
        "$['a']"
      ]
    },
    {
      "name": "name shorthand, extended unicode ☺",
      "selector": "$.☺",
      "document": {
        "☺": "A",
        "b": "B"
      },
      "result": [
        "A"
      ],
      "result_paths": [
        "$['☺']"
      ]
    },
    {
      "name": "name shorthand, underscore",
      "selector": "$._",
      "document": {
        "_": "A",
        "_foo": "B"
      },
      "result": [
        "A"
      ],
      "result_paths": [
        "$['_']"
      ]
    },
    {
      "name": "name shorthand, symbol",
      "selector": "$.&",
      "invalid_selector": true
    },
    {
      "name": "name shorthand, number",
      "selector": "$.1",
      "invalid_selector": true
    },
    {
      "name": "name shorthand, absent data",
      "selector": "$.c",
      "document": {
        "a": "A",
        "b": "B"
      },
      "result": [],
      "result_paths": []
    },
    {
      "name": "name shorthand, array data",
      "selector": "$.a",
      "document": [
        "first",
        "second"
      ],
      "result": [],
      "result_paths": []
    },
    {
      "name": "name shorthand, object data, nested",
      "selector": "$.a.b.c",
      "document": {
        "a": {
          "b": {
            "c": "C"
          }
        }
      },
      "result": [
        "C"
      ],
      "result_paths": [
        "$['a']['b']['c']"
      ]
    },
    {
      "name": "wildcard shorthand, object data",
      "selector": "$.*",
      "document": {
        "a": "A",
        "b": "B"
      },
      "results": [
        [
          "A",
          "B"
        ],
        [
          "B",
          "A"
        ]
      ],
      "results_paths": [
        [
          "$['a']",
          "$['b']"
        ],
        [
          "$['b']",
          "$['a']"
        ]
      ]
    },
    {
      "name": "wildcard shorthand, array data",
      "selector": "$.*",
      "document": [
        "first",
        "second"
      ],
      "result": [
        "first",
        "second"
      ],
      "result_paths": [
        "$[0]",
        "$[1]"
      ]
    },
    {
      "name": "wildcard selector, array data",
      "selector": "$[*]",
      "document": [
        "first",
        "second"
      ],
      "result": [
        "first",
        "second"
      ],
      "result_paths": [
        "$[0]",
        "$[1]"
      ]
    },
    {
      "name": "wildcard shorthand, then name shorthand",
      "selector": "$.*.a",
      "document": {
        "x": {
          "a": "Ax",
          "b": "Bx"
        },
        "y": {
          "a": "Ay",
          "b": "By"
        }
      },
      "results": [
        [
          "Ax",
          "Ay"
        ],
        [
          "Ay",
          "Ax"
        ]
      ],
      "results_paths": [
        [
          "$['x']['a']",
          "$['y']['a']"
        ],
        [
          "$['y']['a']",
          "$['x']['a']"
        ]
      ]
    },
    {
      "name": "multiple selectors",
      "selector": "$[0,2]",
      "document": [
        0,
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9
      ],
      "result": [
        0,
        2
      ],
      "result_paths": [
        "$[0]",
        "$[2]"
      ]
    },
    {
      "name": "multiple selectors, space instead of comma",
      "selector": "$[0 2]",
      "invalid_selector": true,
      "tags": [
        "whitespace"
      ]
    },
    {
      "name": "selector, leading comma",
      "selector": "$[,0]",
      "invalid_selector": true
    },
    {
      "name": "selector, trailing comma",
      "selector": "$[0,]",
      "invalid_selector": true
    },
    {
      "name": "multiple selectors, name and index, array data",
      "selector": "$['a',1]",
      "document": [
        0,
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9
      ],
      "result": [
        1
      ],
      "result_paths": [
        "$[1]"
      ]
    },
    {
      "name": "multiple selectors, name and index, object data",
      "selector": "$['a',1]",
      "document": {
        "a": 1,
        "b": 2
      },
      "result": [
        1
      ],
      "result_paths": [
        "$['a']"
      ]
    },
    {
      "name": "multiple selectors, index and slice",
      "selector": "$[1,5:7]",
      "document": [
        0,
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9
      ],
      "result": [
        1,
        5,
        6
      ],
      "result_paths": [
        "$[1]",
        "$[5]",
        "$[6]"
      ]
    },
    {
      "name": "multiple selectors, index and slice, overlapping",
      "selector": "$[1,0:3]",
      "document": [
        0,
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9
      ],
      "result": [
        1,
        0,
        1,
        2
      ],
      "result_paths": [
        "$[1]",
        "$[0]",
        "$[1]",
        "$[2]"
      ]
    },
    {
      "name": "multiple selectors, duplicate index",
      "selector": "$[1,1]",
      "document": [
        0,
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9
      ],
      "result": [
        1,
        1
      ],
      "result_paths": [
        "$[1]",
        "$[1]"
      ]
    },
    {
      "name": "multiple selectors, wildcard and index",
      "selector": "$[*,1]",
      "document": [
        0,
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9
      ],
      "result": [
        0,
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        1
      ],
      "result_paths": [
        "$[0]",
        "$[1]",
        "$[2]",
        "$[3]",
        "$[4]",
        "$[5]",
        "$[6]",
        "$[7]",
        "$[8]",
        "$[9]",
        "$[1]"
      ]
    },
    {
      "name": "multiple selectors, wildcard and name",
      "selector": "$[*,'a']",
      "document": {
        "a": "A",
        "b": "B"
      },
      "results": [
        [
          "A",
          "B",
          "A"
        ],
        [
          "B",
          "A",
          "A"
        ]
      ],
      "results_paths": [
        [
          "$['a']",
          "$['b']",
          "$['a']"
        ],
        [
          "$['b']",
          "$['a']",
          "$['a']"
        ]
      ]
    },
    {
      "name": "multiple selectors, wildcard and slice",
      "selector": "$[*,0:2]",
      "document": [
        0,
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9
      ],
      "result": [
        0,
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        0,
        1
      ],
      "result_paths": [
        "$[0]",
        "$[1]",
        "$[2]",
        "$[3]",
        "$[4]",
        "$[5]",
        "$[6]",
        "$[7]",
        "$[8]",
        "$[9]",
        "$[0]",
        "$[1]"
      ]
    },
    {
      "name": "multiple selectors, multiple wildcards",
      "selector": "$[*,*]",
      "document": [
        0,
        1,
        2
      ],
      "result": [
        0,
        1,
        2,
        0,
        1,
        2
      ],
      "result_paths": [
        "$[0]",
        "$[1]",
        "$[2]",
        "$[0]",
        "$[1]",
        "$[2]"
      ]
    },
    {
      "name": "empty segment",
      "selector": "$[]",
      "invalid_selector": true
    },
    {
      "name": "descendant segment, index",
      "selector": "$..[1]",
      "document": {
        "o": [
          0,
          1,
          [
            2,
            3
          ]
        ]
      },
      "result": [
        1,
        3
      ],
      "result_paths": [
        "$['o'][1]",
        "$['o'][2][1]"
      ]
    },
    {
      "name": "descendant segment, name shorthand",
      "selector": "$..a",
      "document": {
        "o": [
          {
            "a": "b"
          },
          {
            "a": "c"
          }
        ]
      },
      "result": [
        "b",
        "c"
      ],
      "result_paths": [
        "$['o'][0]['a']",
        "$['o'][1]['a']"
      ]
    },
    {
      "name": "descendant segment, wildcard shorthand, array data",
      "selector": "$..*",
      "document": [
        0,
        1
      ],
      "result": [
        0,
        1
      ],
      "result_paths": [
        "$[0]",
        "$[1]"
      ]
    },
    {
      "name": "descendant segment, wildcard selector, array data",
      "selector": "$..[*]",
      "document": [
        0,
        1
      ],
      "result": [
        0,
        1
      ],
      "result_paths": [
        "$[0]",
        "$[1]"
      ]
    },
    {
      "name": "descendant segment, wildcard selector, nested arrays",
      "selector": "$..[*]",
      "document": [
        [
          [
            1
          ]
        ],
        [
          2
        ]
      ],
      "results": [
        [
          [
            [
              1
            ]
          ],
          [
            2
          ],
          [
            1
          ],
          1,
          2
        ],
        [
          [
            [
              1
            ]
          ],
          [
            2
          ],
          [
            1
          ],
          2,
          1
        ]
      ],
      "results_paths": [
        [
          "$[0]",
          "$[1]",
          "$[0][0]",
          "$[0][0][0]",
          "$[1][0]"
        ],
        [
          "$[0]",
          "$[1]",
          "$[0][0]",
          "$[1][0]",
          "$[0][0][0]"
        ]
      ]
    },
    {
      "name": "descendant segment, wildcard selector, nested objects",
      "selector": "$..[*]",
      "document": {
        "a": {
          "c": {
            "e": 1
          }
        },
        "b": {
          "d": 2
        }
      },
      "results": [
        [
          {
            "c": {
              "e": 1
            }
          },
          {
            "d": 2
          },
          {
            "e": 1
          },
          1,
          2
        ],
        [
          {
            "c": {
              "e": 1
            }
          },
          {
            "d": 2
          },
          {
            "e": 1
          },
          2,
          1
        ],
        [
          {
            "c": {
              "e": 1
            }
          },
          {
            "d": 2
          },
          2,
          {
            "e": 1
          },
          1
        ],
        [
          {
            "d": 2
          },
          {
            "c": {
              "e": 1
            }
          },
          {
            "e": 1
          },
          1,
          2
        ],
        [
          {
            "d": 2
          },
          {
            "c": {
              "e": 1
            }
          },
          {
            "e": 1
          },
          2,
          1
        ],
        [
          {
            "d": 2
          },
          {
            "c": {
              "e": 1
            }
          },
          2,
          {
            "e": 1
          },
          1
        ]
      ],
      "results_paths": [
        [
          "$['a']",
          "$['b']",
          "$['a']['c']",
          "$['a']['c']['e']",
          "$['b']['d']"
        ],
        [
          "$['a']",
          "$['b']",
          "$['a']['c']",
          "$['b']['d']",
          "$['a']['c']['e']"
        ],
        [
          "$['a']",
          "$['b']",
          "$['b']['d']",
          "$['a']['c']",
          "$['a']['c']['e']"
        ],
        [
          "$['b']",
          "$['a']",
          "$['a']['c']",
          "$['a']['c']['e']",
          "$['b']['d']"
        ],
        [
          "$['b']",
          "$['a']",
          "$['a']['c']",
          "$['b']['d']",
          "$['a']['c']['e']"
        ],
        [
          "$['b']",
          "$['a']",
          "$['b']['d']",
          "$['a']['c']",
          "$['a']['c']['e']"
        ]
      ]
    },
    {
      "name": "descendant segment, wildcard shorthand, object data",
      "selector": "$..*",
      "document": {
        "a": "b"
      },
      "result": [
        "b"
      ],
      "result_paths": [
        "$['a']"
      ]
    },
    {
      "name": "descendant segment, wildcard shorthand, nested data",
      "selector": "$..*",
      "document": {
        "o": [
          {
            "a": "b"
          }
        ]
      },
      "result": [
        [
          {
            "a": "b"
          }
        ],
        {
          "a": "b"
        },
        "b"
      ],
      "result_paths": [
        "$['o']",
        "$['o'][0]",
        "$['o'][0]['a']"
      ]
    },
    {
      "name": "descendant segment, multiple selectors",
      "selector": "$..['a','d']",
      "document": [
        {
          "a": "b",
          "d": "e"
        },
        {
          "a": "c",
          "d": "f"
        }
      ],
      "result": [
        "b",
        "e",
        "c",
        "f"
      ],
      "result_paths": [
        "$[0]['a']",
        "$[0]['d']",
        "$[1]['a']",
        "$[1]['d']"
      ]
    },
    {
      "name": "descendant segment, object traversal, multiple selectors",
      "selector": "$..['a','d']",
      "document": {
        "x": {
          "a": "b",
          "d": "e"
        },
        "y": {
          "a": "c",
          "d": "f"
        }
      },
      "results": [
        [
          "b",
          "e",
          "c",
          "f"
        ],
        [
          "c",
          "f",
          "b",
          "e"
        ]
      ],
      "results_paths": [
        [
          "$['x']['a']",
          "$['x']['d']",
          "$['y']['a']",
          "$['y']['d']"
        ],
        [
          "$['y']['a']",
          "$['y']['d']",
          "$['x']['a']",
          "$['x']['d']"
        ]
      ]
    },
    {
      "name": "bald descendant segment",
      "selector": "$..",
      "invalid_selector": true
    },
    {
      "name": "current node identifier without filter selector",
      "selector": "$[@.a]",
      "invalid_selector": true
    },
    {
      "name": "root node identifier in brackets without filter selector",
      "selector": "$[$.a]",
      "invalid_selector": true
    }
  ]
}
