summaryrefslogtreecommitdiffstats
path: root/docs/content
diff options
context:
space:
mode:
authorStephen Dolan <mu@netsoc.tcd.ie>2012-12-29 22:59:07 +0000
committerStephen Dolan <mu@netsoc.tcd.ie>2012-12-29 22:59:07 +0000
commitb3bad59dd7d9fcea575ef2de2843b9515b0630b4 (patch)
tree428463436b5e4a194b3c7ef1a251f6dc928836e0 /docs/content
parente0cda536f331b0fc53b493069dce70bb32de9a8b (diff)
Add the `recurse` function. See #37.
Diffstat (limited to 'docs/content')
-rw-r--r--docs/content/3.manual/manual.yml32
1 files changed, 32 insertions, 0 deletions
diff --git a/docs/content/3.manual/manual.yml b/docs/content/3.manual/manual.yml
index fba7e4a7..de608210 100644
--- a/docs/content/3.manual/manual.yml
+++ b/docs/content/3.manual/manual.yml
@@ -643,6 +643,38 @@ sections:
input: '{"foo": 12, "bar":[1,2,{"barp":12, "blip":13}]}'
output: ['false']
+ - title: `recurse`
+ body: |
+
+ The `recurse` function allows you to search through a
+ recursive structure, and extract interesting data from all
+ levels. Suppose your input represents a filesystem:
+
+ {"name": "/", "children": [
+ {"name": "/bin", "children": [
+ {"name": "/bin/ls", "children": []},
+ {"name": "/bin/sh", "children": []}]},
+ {"name": "/home", "children": [
+ {"name": "/home/stephen", "children": [
+ {"name": "/home/stephen/jq", "children": []}]}]}]}
+
+ Now suppose you want to extract all of the filenames
+ present. You need to retrieve `.name`, `.children[].name`,
+ `.children[].children[].name`, and so on. You can do this
+ with:
+
+ recurse(.children[]) | .name
+
+ examples:
+ - program: 'recurse(.foo[])'
+ input: '{"foo":[{"foo": []}, {"foo":[{"foo":[]}]}]}'
+ output:
+ - '{"foo":[{"foo":[]},{"foo":[{"foo":[]}]}]}'
+ - '{"foo":[]}'
+ - '{"foo":[{"foo":[]}]}'
+ - '{"foo":[]}'
+
+
- title: "String interpolation - `\(foo)`"
body: |