diff options
Diffstat (limited to 'tests/shell/helpers/json-pretty.sh')
-rwxr-xr-x | tests/shell/helpers/json-pretty.sh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/shell/helpers/json-pretty.sh b/tests/shell/helpers/json-pretty.sh new file mode 100755 index 00000000..0d6972b8 --- /dev/null +++ b/tests/shell/helpers/json-pretty.sh @@ -0,0 +1,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)) +' |