diff options
author | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-12-13 11:07:26 +0100 |
---|---|---|
committer | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-12-13 13:59:39 +0100 |
commit | 80a68ceb5aa7ea37670842fbd427d98c9c01d808 (patch) | |
tree | 04ec565e1159f926bfde599bcd896adab2528c2e /cli/utils.py | |
parent | 12d965ce1c1497df6f5d5a63fd562171ce01b9e7 (diff) |
live: use human readable date in live list
Parse the unix timestamp into a human readable format like
"2024-11-25 12:28:19".
Make print_json() print from string and from a json object to
enable manipulation of data before printing.
Diffstat (limited to 'cli/utils.py')
-rw-r--r-- | cli/utils.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/cli/utils.py b/cli/utils.py index 380bd5b..2922f78 100644 --- a/cli/utils.py +++ b/cli/utils.py @@ -49,8 +49,11 @@ def reorder_json_tree(payload): payload[k] = val reorder_json_tree(val) -def print_json(text): - payload = json.loads(text) +def print_json(data): + if isinstance(data, (dict, list)): + payload = data + else: + payload = json.loads(data) reorder_json_tree(payload) print(json.dumps(payload, indent=2, ensure_ascii=False)) |