Walk over a parsed JSON nested structure `d`, apply `func` to each leaf element and replace it with result

def walk_json(d, func):
    """ Walk over a parsed JSON nested structure `d`, apply `func` to each leaf element and replace it with result
    """
    if isinstance(d, Mapping):
        return OrderedDict((k, walk_json(v, func)) for k, v in d.items())
    elif isinstance(d, list):
        return [walk_json(v, func) for v in d]
    else:
        return func(d)