From 51ea3780766b1d3dacf0b2c87703d3b95d95aa38 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sat, 6 Apr 2019 23:42:39 -0400 Subject: Adding coll.JSONPath function Signed-off-by: Dave Henderson --- docs-src/content/functions/coll.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'docs-src') diff --git a/docs-src/content/functions/coll.yml b/docs-src/content/functions/coll.yml index b00c14b0..58fb9b3f 100644 --- a/docs-src/content/functions/coll.yml +++ b/docs-src/content/functions/coll.yml @@ -83,6 +83,28 @@ funcs: $ gomplate -i '{{ $o := data.JSON (getenv "DATA") -}} {{ if (has $o "foo") }}{{ $o.foo }}{{ else }}THERE IS NO FOO{{ end }}' THERE IS NO FOO + - name: conv.JSONPath + alias: jsonpath + description: | + Extracts portions of an input object or list using a [JSONPath][] expression. + + Any object or list may be used as input. The output depends somewhat on the expression; if multiple items are matched, an array is returned. + + JSONPath expressions can be validated at https://jsonpath.com + + [JSONPath]: https://goessner.net/articles/JsonPath + pipeline: true + arguments: + - name: expression + required: true + description: The JSONPath expression + - name: in + required: true + description: The object or list to query + examples: + - | + $ gomplate -i '{{ .books | jsonpath `$..works[?( @.edition_count > 400 )].title` }}' -c books=https://openlibrary.org/subjects/fantasy.json + [Alice's Adventures in Wonderland Gulliver's Travels] - name: coll.Keys alias: keys description: | -- cgit v1.2.3