summaryrefslogtreecommitdiffstats
path: root/tests/shell/helpers/json-pretty.sh
blob: 0d6972b81e2f0bac8501b66c2c7cd30425be3a35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash -e

# WARNING: the output is not guaranteed to be stable.

if command -v jq &>/dev/null ; then
	# If we have, use `jq`
	exec jq
fi

# Fallback to python.
exec python -c '
import json
import sys

parsed = json.load(sys.stdin)
print(json.dumps(parsed, indent=2))
'