def serialize_positional_argument(argument_type, argument_value):
    """
    Serialize the provided positional argument.

    Note: Serialization is NOT performed recursively since it doesn't make much
    sense for shell script actions (only the outter / top level value is
    serialized).
    """
    if argument_type in ["string", "number", "float"]:
        if argument_value is None:
            argument_value = six.text_type("")
            return argument_value

        if isinstance(argument_value, (int, float)):
            argument_value = str(argument_value)

        if not isinstance(argument_value, six.text_type):
            # cast string non-unicode values to unicode
            argument_value = argument_value.decode("utf-8")
    elif argument_type == "boolean":
        # Booleans are serialized as string "1" and "0"
        if argument_value is not None:
            argument_value = "1" if bool(argument_value) else "0"
        else:
            argument_value = ""
    elif argument_type in ["array", "list"]:
        # Lists are serialized a comma delimited string (foo,bar,baz)
        argument_value = ",".join(map(str, argument_value)) if argument_value else ""
    elif argument_type == "object":
        # Objects are serialized as JSON
        argument_value = json_encode(argument_value) if argument_value else ""
    elif argument_type == "null":
        # None / null is serialized as en empty string
        argument_value = ""
    else:
        # Other values are simply cast to unicode string
        argument_value = six.text_type(argument_value) if argument_value else ""

    return argument_value

    Serialize the provided positional argument.

    Note: Serialization is NOT performed recursively since it doesn't make much
    sense for shell script actions (only the outter / top level value is
    serialized).
    
st2common/st2common/util/action_db.py