I have a json string and I want to know what its maximum depth is. By depth I mean the number of embedded keys. So if one key as 7 \"children\" and know other key had that
Here's one implementation:
def depth(x): if type(x) is dict and x: return 1 + max(depth(x[a]) for a in x) if type(x) is list and x: return 1 + max(depth(a) for a in x) return 0