@generic
def fromjson(datatype, value):
    if value is None:
        return None
    if iscomplex(datatype):
        newvalue = datatype()
        for attrdef in list_attributes(datatype):
            if attrdef.name in value:
                setattr(newvalue, attrdef.key,
                        fromjson(attrdef.datatype, value[attrdef.name]))
        value = newvalue
    elif isusertype(datatype):
        value = datatype.frombasetype(fromjson(datatype.basetype, value))
    return value
dataset/ETHPy150Open openstack/wsme/wsmeext/extdirect/protocol.py/fromjson/original