JsonPath

class aws_cdk.aws_stepfunctions.JsonPath(*args: Any, **kwargs)

Bases: object

Extract a field from the State Machine data or context that gets passed around between states.

See:

https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-paths.html

ExampleMetadata:

infused

Example:

# fn: lambda.Function

tasks.LambdaInvoke(self, "Invoke Handler",
    lambda_function=fn,
    result_selector={
        "lambda_output": sfn.JsonPath.string_at("$.Payload"),
        "invoke_request_id": sfn.JsonPath.string_at("$.SdkResponseMetadata.RequestId"),
        "static_value": {
            "foo": "bar"
        },
        "state_name": sfn.JsonPath.string_at("$.State.Name")
    }
)

Attributes

DISCARD = 'DISCARD'
entire_context = '${Token[TOKEN.249]}'
entire_payload = '${Token[TOKEN.250]}'
task_token = '${Token[Task.Token.251]}'

Static Methods

classmethod array(*values)

Make an intrinsic States.Array expression.

Combine any number of string literals or JsonPath expressions into an array.

Use this function if the value of an array element directly has to come from a JSON Path expression (either the State object or the Context object).

If the array contains object literals whose values come from a JSON path expression, you do not need to use this function.

Parameters:

values (str) –

See:

https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html

Return type:

str

classmethod format(format_string, *values)

Make an intrinsic States.Format expression.

This can be used to embed JSON Path variables inside a format string.

For example:

sfn.JsonPath.format("Hello, my name is {}.", sfn.JsonPath.string_at("$.name"))
Parameters:
  • format_string (str) –

  • values (str) –

See:

https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html

Return type:

str

classmethod is_encoded_json_path(value)

Determines if the indicated string is an encoded JSON path.

Parameters:

value (str) – string to be evaluated.

Return type:

bool

classmethod json_to_string(value)

Make an intrinsic States.JsonToString expression.

During the execution of the Step Functions state machine, encode the given object into a JSON string.

For example:

sfn.JsonPath.json_to_string(sfn.JsonPath.object_at("$.someObject"))
Parameters:

value (Any) –

See:

https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html

Return type:

str

classmethod list_at(path)

Instead of using a literal string list, get the value from a JSON path.

Parameters:

path (str) –

Return type:

List[str]

classmethod number_at(path)

Instead of using a literal number, get the value from a JSON path.

Parameters:

path (str) –

Return type:

Union[int, float]

classmethod object_at(path)

Reference a complete (complex) object in a JSON path location.

Parameters:

path (str) –

Return type:

IResolvable

classmethod string_at(path)

Instead of using a literal string, get the value from a JSON path.

Parameters:

path (str) –

Return type:

str

classmethod string_to_json(json_string)

Make an intrinsic States.StringToJson expression.

During the execution of the Step Functions state machine, parse the given argument as JSON into its object form.

For example:

sfn.JsonPath.string_to_json(sfn.JsonPath.string_at("$.someJsonBody"))
Parameters:

json_string (str) –

See:

https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html

Return type:

IResolvable