def _cast_object(x):
    """
    Method for casting string to an object (dict) or array.

    Note: String can be either serialized as JSON or a raw Python output.
    """
    x = _cast_none(x)

    if isinstance(x, six.string_types):
        try:
            return json_decode(x)
        except:
            return ast.literal_eval(x)
    else:
        return x

    Method for casting string to an object (dict) or array.

    Note: String can be either serialized as JSON or a raw Python output.
    
st2common/st2common/util/casts.py