Skip to content

[Feature Request]: Add the possibility to add a JSON object at the endpoint to run tasks #426

@puchy22

Description

@puchy22

Feature Description

Enable the API to return task results as Any or JSON objects instead of limiting them to plain strings.

Reason

Currently, the result of a Workflow can be of any type, as specified in the result parameter of a Stop event. However, the API only supports returning results as strings. Expanding this to include JSON objects would enhance the API's ability to represent complex data structures more accurately. JSON support is particularly valuable because, while casting simple types like integers from strings is straightforward, handling more complex structures like dictionaries becomes cumbersome and error-prone when parsing strings, especially with multiple keys and values.

Example

Suppose a Workflow returns the following Stop event:

return StopEvent(
    result={
        "key-1": "value-1",
        "key-2": {
            "nested-key": 42,
            "nested-list": [1, 2, 3]
        }
    }
)

Currently, the API would return this as a string like:
"{'key-1': 'value-1', 'key-2': {'nested-key': 42, 'nested-list': [1, 2, 3]}}"

To use this output, a consumer of the API would need to parse it back into a dictionary, which can be error-prone and inefficient, especially for deeply nested structures. With the proposed change, the API would return a proper JSON object like:

{
    "key-1": "value-1",
    "key-2": {
        "nested-key": 42,
        "nested-list": [1, 2, 3]
    }
}

This structured format eliminates the need for manual parsing and ensures compatibility with modern HTTP consumers.

Value of Feature

This feature simplifies the consumption of API results by allowing structured data to be returned directly. For instance, when a Workflow processes data and produces structured output (e.g., dictionaries), users won't need to manually parse a string representation, which might be infeasible for complex data. By supporting JSON objects, the API becomes more user-friendly, particularly for developers integrating workflows with HTTP-based systems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions