comparison json_flatten.py @ 0:8956e949d466 draft default tip

planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/dfpl commit 66c6acfeff5441c36fba97787ddc5ee3d6a4a6ec
author ufz
date Thu, 19 Dec 2024 12:51:08 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:8956e949d466
1 import json
2 from sys import stdin
3
4 d = json.load(stdin)
5
6
7 def flatten(o: dict):
8 d_flat = {}
9 for key, value in o.items():
10 if type(value) is dict:
11 value = flatten(value)
12 for k, v in value.items():
13 d_flat[k] = v
14 else:
15 d_flat[key] = value
16 return d_flat
17
18
19 d = flatten(d)
20
21 print(json.dumps(d))