jpipe
Render json with go templates from the command line
Docker
curl --silent https://jsonplaceholder.typicode.com/users/1 \
| docker run --interactive bluebrown/jpipe \
--newline '{{.name}}'
Local
go get github.com/bluebrown/jpipe
Usage
The templates are executed with the text/template package. That means so they are not injection safe while providing greater flexibility for the user. don't execute untrusted templates!
$ echo '{"place": "bar"}' | jpipe 'lets go to the {{.place}}!'
lets go to the bar!
The template is either read from the first positional argument or from a path specified via --template
or -t
flag.
echo '{"place": "bar"}' | jpipe --template path/to/template
The json input is read from pipe or redirection.
jpipe < path/to/input.json
curl localhost | jpipe
Flags
-n
-newline
print new line at the end
-t string
-template string
alternative way to specify template
Sprig
Sprig functions have been added to provide more…