[
    {
        "given" : [2, "a", 4, 5, 100, "nice"],
        "cases" : [
            {
                "source" : "https://github.com/cburgmer/json-path-comparison",
                "comment" : "Array slice with negative start and end and range of -1",
                "expression" : "$[-4:-5]",
                "result" : [] 
            },
            {
                "source" : "https://github.com/cburgmer/json-path-comparison",
                "comment" : "Array slice with negative start and end and range of 0",
                "expression" : "$[-4:-4]",
                "result" : [] 
            },
            {
                "comment" : "Array slice with negative start and end and range of 1",
                "expression" : "$[-4:-3]",
                "result" : [4] 
            },
            {
                "source" : "https://github.com/cburgmer/json-path-comparison",
                "comment" : "Array slice with negative start and positive end and range of -1",
                "expression" : "$[-4:1]",
                "result" : [] 
            }
        ]
    },
    {
        "source" : "https://github.com/cburgmer/json-path-comparison",
        "given" : ["first", "second", "third", "forth", "fifth"],
        "cases" : [
            {
                "comment" : "Last item",
                "expression" : "$[-1]",
                "result" : ["fifth"]
            },
            {
                "comment" : "Last two items",
                "expression" : "$[-2:]",
                "result" : ["forth", "fifth"],
                "path" : ["$[3]", "$[4]"]
            },
            {
                "comment" : "Last two items, nodups",
                "expression" : "$[-2:]",
                "result" : ["forth", "fifth"],
                "path" : ["$[3]", "$[4]"],
                "nodups" : true
            },
            {
                "comment" : "All items except the last two",
                "expression" : "$[:-2]",
                "result" : ["first", "second", "third"]
            },
            {
                "comment" : "All items, reversed",
                "expression" : "$[::-1]",
                "result" : ["fifth","forth","third","second","first"]
            },
            {
                "comment" : "First two items, reversed",
                "expression" : "$[1::-1]",
                "result" : ["second","first"]
            },
            {
                "comment" : "Last two items, reversed",
                "expression" : "$[:-3:-1]",
                "result" : ["fifth","forth"]
            },
            {
                "comment" : "All items except the last two, reversed",
                "expression" : "$[-3::-1]",
                "result" : ["third","second","first"]
            },
            {
                "comment" : "array index",
                "expression" : "$[2]",
                "result" : ["third"]
            },
            {
                "comment" : "Array index slice start end step 0",
                "expression" : "$[0:3:0]",
                "error" : "Slice step cannot be zero at line 1 and column 8"
            },
            {
                "comment" : "Array slice with negative step",
                "expression" : "$[3:0:-2]",
                "result" : ["forth","second"] 
            },
            {
                "comment" : "Array slice with negative step on partially overlapping array",
                "expression" : "$[7:3:-1]",
                "result" : ["fifth"] 
            },
            {
                "comment" : "Array slice with negative step and start greater than end",
                "expression" : "$[0:3:-2]",
                "result" : [] 
            },
            {
                "comment" : "Array slice with negative step and start greater than end",
                "expression" : "$[0:3:-2]",
                "result" : [] 
            },
            {
                "comment" : "Array slice with negative step and start greater than end",
                "expression" : "$[::-2]",
                "result" : ["fifth","third","first"] 
            },
            {
                "comment" : "Array slice with open end",
                "expression" : "$[1:]",
                "result" : ["second", "third", "forth", "fifth"]
            },
            {
                "comment" : "Array slice with open end and negative step",
                "expression" : "$[3::-1]",
                "result" : ["forth","third","second","first"]
            },
            {
                "comment" : "Array slice with open start",
                "expression" : "$[:2]",
                "result" : ["first", "second"]
            }
        ]
    },
    {
        "given" : ["first", "second"],
        "cases" : [
            {
                "comment" : "Array slice with open start and end",
                "expression" : "$[:]",
                "result" : ["first", "second"]
            },
            {
                "comment" : "Array slice with open start and end and step empty",
                "expression" : "$[::]",
                "result" : ["first", "second"]
            }
        ]
    },
    {
        "given" : ["first", "second", "third", "forth", "fifth"],
        "cases" : [
            {
                "comment" : "Array slice",
                "expression" : "$[1:3]",
                "result" : ["second","third"]
            },
            {
                "comment" : "Array slice on exact match",
                "expression" : "$[0:5]",
                "result" : ["first","second","third","forth","fifth"]
            },
            {
                "comment" : "Array slice with large number for end",
                "expression" : "$[2:113667776004]",
                "result" : ["third","forth","fifth"]
            },
            {
                "comment" : "Array slice with large number for end and negative step",
                "expression" : "$[2:-113667776004:-1]",
                "result" : ["third","second","first"]
            },
            {
                "comment" : "Array slice with large number for start",
                "expression" : "$[-113667776004:2]",
                "result" : ["first","second"]
            },
            {
                "comment" : "Array slice with large number for start end negative step",
                "expression" : "$[113667776004:2:-1]",
                "result" : ["fifth","forth"]
            }
        ]
    },
    {
        "given" : ["first", "second", "third"],
        "cases" : [
            {
                "comment" : "Array slice on non overlapping array",
                "expression" : "$[7:10]",
                "result" : []
            },
            {
                "comment" : "Array slice on partially overlapping array",
                "expression" : "$[1:10]",
                "result" : ["second","third"]
            }
        ]
    },
    {
        "given" : {":": 42, "more": "string", "a": 1, "b": 2, "c": 3, "1:3": "nice"},
        "cases" : [
            {
                "comment" : "Array slice on object",
                "expression" : "$[1:3]",
                "result" : []
            }
        ]
    },
    {
        "given" : [{"key": "ey"}, {"key": "bee"}, {"key": "see"}],
        "cases" : [
            {
                "comment" : "Dot notation after array slice",
                "expression" : "$[0:2].key",
                "result" : ["ey","bee"]
            }
        ]
    }, 
    {
     "given": {
       "foo": [{"a": 1}, {"a": 2}, {"a": 3}],
       "bar": [{"a": {"b": 1}}, {"a": {"b": 2}},
   	    {"a": {"b": 3}}],
       "baz": 50
     },
     "cases": [
       {
         "expression": "$.foo[:2].a",
         "result": [1, 2]
       },
       {
         "expression": "$.foo[:2].b",
         "result": []
       },
       {
         "expression": "$.foo[:2].a.b",
         "result": []
       },
       {
         "expression": "$.bar[::-1].a.b",
         "result": [3, 2, 1]
       }
       ,
       {
         "expression": "$.bar[:2].a.b",
         "result": [1, 2]
       },
       {
         "expression": "$.baz[:2].a",
         "result": []
       }
     ]
   }
]
