Very simple script to get json input, pass it via Jinja2 template to get the output.
Why? Sometimes I got some simple json file and I want to process it into something easier to read, for example text file or html.
Other tools usually do too much already, like extra connecting to internet idk why...
- not providing pip package, I'm too lazy and this is too simple to package it anyway.... or docker, yeaaaaaaahhh ;)
- template used is TOTALLY dependent on json file used as input, see examples
- pretty sure it requires python
- may require Jinja2
render.py --help
python render.py \
-i examples/aws_ecr_scan_result.json \
-t templates/aws_ecr_scan_result_plaintext_short.j2 \
-o examples/aws_ecr_scan_result_plaintext_short.txt
python render.py \
-i examples/aws_ecr_scan_result.json \
-t templates/aws_ecr_scan_result_plaintext_long.j2 \
-o examples/aws_ecr_scan_result_plaintext_long.txt
This is a bit more useful :)
python render.py \
-i examples/aws_ecr_scan_result.json \
-t templates/aws_ecr_scan_result_html.j2 \
-o examples/aws_ecr_scan_result_html.html
Fully rendered output here.
cat examples/aws_ecr_scan_result.json \
| docker run -v $(pwd)/templates/:/app/templates:ro -i quay.io/kaszpir/python-json-via-jinja2-render -t templates/aws_ecr_scan_result_html.j2 \
> output.html
or:
docker run \
-v "$(pwd)/templates/:/app/templates:ro" \
-i quay.io/kaszpir/python-json-via-jinja2-render \
-t templates/aws_ecr_scan_result_html.j2 \
<examples/aws_ecr_scan_result.json \
>output.html
- Create
my_template
dir with desired template - write
my_template/custom.j2
file which is tailored to your json input files - Run command to get output to stdout:
cat examples/aws_ecr_scan_result.json \
| docker run -v $(pwd)/my_template/:/app/templates:ro -i quay.io/kaszpir/python-json-via-jinja2-render -t templates/custom.j2 \
> output.html