Spaces:
Sleeping
Sleeping
| # 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 |