Very simple demo to show how to use the template engine of Golang. It's called hydrator as it could form the basis of a templated/JSON data hydrator.
- Takes in JSON input (try
source.json
) - Go through the JSON and apply the transformations dictated in external template (try
transform.tmpl
) - Print formatted JSON to standard out
Hacked together in about 30 mins so don't judge me - and if you find it useful, open a PR and tidy it up!
go get -u github.com/17twenty/hydrator
hydrator -s <source JSON file> -t <transformation template> [-w <output.json>]
It would be really cool to use the plugins
capability to dynamically add new
template functions. I'll leave that to someone else tho.