diff options
author | Stephen Dolan <mu@netsoc.tcd.ie> | 2013-05-13 20:16:19 +0100 |
---|---|---|
committer | Stephen Dolan <mu@netsoc.tcd.ie> | 2013-05-13 20:16:19 +0100 |
commit | 33901b74b16ce037c732d7a33444862d93c91065 (patch) | |
tree | 3bdbf1472b31187a665dd7b601f04ad869473b49 /docs/content/3.manual | |
parent | a47cfa475700469d0ea0e7a7c80c5fef8690ac3f (diff) |
Array slicing. Closes #2.
Diffstat (limited to 'docs/content/3.manual')
-rw-r--r-- | docs/content/3.manual/manual.yml | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/docs/content/3.manual/manual.yml b/docs/content/3.manual/manual.yml index 766fef7b..b88c4c22 100644 --- a/docs/content/3.manual/manual.yml +++ b/docs/content/3.manual/manual.yml @@ -160,7 +160,7 @@ sections: input: '{"notfoo": true, "alsonotfoo": false}' output: ['null'] - - title: "`.[foo]`" + - title: "`.[foo]`, `.[2]`, `.[10:15]`" body: | You can also look up fields of an object using syntax like @@ -169,6 +169,13 @@ sections: integer. Arrays are zero-based (like javascript), so `.[2]` returns the third element of the array. + The `.[10:15]` syntax can be used to return a subarray of an + array. The array returned by `.[10:15]` will be of length 5, + containing the elements from index 10 (inclusive) to index + 15 (exclusive). Either index may be negative (in which case + it counts backwards from the end of the array), or omitted + (in which case it refers to the start or end of the array). + examples: - program: '.[0]' input: '[{"name":"JSON", "good":true}, {"name":"XML", "good":false}]' @@ -178,6 +185,18 @@ sections: input: '[{"name":"JSON", "good":true}, {"name":"XML", "good":false}]' output: ['null'] + - program: '.[2:4]' + input: '["a","b","c","d","e"]' + output: ['["c", "d"]'] + + - program: '.[:3]' + input: '["a","b","c","d","e"]' + output: ['["a", "b", "c"]'] + + - program: '.[-2:]' + input: '["a","b","c","d","e"]' + output: ['["d", "e"]'] + - title: "`.[]`" body: | |