Spaces:
Sleeping
Sleeping
File size: 370 Bytes
8f062e6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# Flatten the JSON data
def flatten_json(y):
out = {}
def flatten(x, name=''):
if type(x) is dict:
for a in x:
flatten(x[a], f"{name}{a}_")
elif type(x) is list:
for i, a in enumerate(x):
flatten(a, f"{name}{i}_")
else:
out[name[:-1]] = x
flatten(y)
return out |