def decode4js(obj):
    out = obj
    if isinstance(obj, dict):
        classname = obj.pop('__class__', None)
        if classname is None:
            return obj
        elif classname == 'Complex':
            out = obj['value'][0] + 1j*obj['value'][1]
        elif classname in ('List', 'Tuple'):
            out = []
            for item in obj['value']:
                out.append(decode4js(item))
            if classname == 'Tuple':
                out = tuple(out)
        elif classname == 'Array':
            if obj['__dtype__'].startswith('complex'):
                re = np.fromiter(obj['value'][0], dtype='double')
                im = np.fromiter(obj['value'][1], dtype='double')
                out = re + 1j*im
            else:
                out = np.fromiter(obj['value'], dtype=obj['__dtype__'])
            out.shape = obj['__shape__']
        elif classname in ('Dict', 'Parameter', 'Group'):
            out = {}
            for key, val in obj.items():
                out[key] = decode4js(val)
            if classname == 'Parameter':
                out = Parameter(**out)
            elif classname == 'Group':
                out = Group(**out)
    return out
return decoded Python object from encoded object.
dataset/ETHPy150Open xraypy/xraylarch/lib/utils/jsonutils.py/decode4js