def deserialize(obj):
    """Convert JSON dicts back into objects."""
    # Be careful of shallow copy here
    target = dict(obj)
    class_name = None
    if '__class__' in target:
        class_name = target.pop('__class__')
    if '__module__' in obj:
        obj.pop('__module__')
    # Use getattr(module, class_name) for custom types if needed
    if class_name == 'datetime':
        return datetime.datetime(tzinfo=utc, **target)
    if class_name == 'StreamingBody':
        return StringIO(target['body'])
    # Return unrecognized structures as-is
    return obj
def deserialize ( obj ) : target = dict ( obj ) class_name = None if '__class__' in target : class_name = target . pop ( '__class__' ) if '__module__' in obj : obj . pop ( '__module__' ) if class_name == 'datetime' : return datetime . datetime ( tzinfo = utc , ** target ) if class_name == 'StreamingBody' : return StringIO ( target [ 'body' ] ) return obj
Convert JSON dicts back into objects.