<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def encode_conjure_union_type(cls, obj):
 # type: (ConjureUnionType) -> Any """Encodes a conjure union into json"""

        encoded = {}  # type: Dict[str, Any]
        encoded["type"] = obj.type
        for attr, field_definition in obj._options().items():
            if field_definition.identifier == obj.type:
                attribute = attr
                break
        else:
            raise ValueError(
                "could not find attribute for union " +
                "member {0} of type {1}".format(obj.type, obj.__class__)
            )

        defined_field_definition = obj._options()[attribute]
        encoded[defined_field_definition.identifier] = cls.do_encode(
            getattr(obj, attribute)
        )
        return encoded