class JsonPath
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.StepFunctions.JsonPath |
![]() | software.amazon.awscdk.services.stepfunctions.JsonPath |
![]() | aws_cdk.aws_stepfunctions.JsonPath |
![]() | @aws-cdk/aws-stepfunctions » JsonPath |
Extract a field from the State Machine data or context that gets passed around between states.
Example
declare const fn: lambda.Function;
new tasks.LambdaInvoke(this, 'Invoke Handler', {
lambdaFunction: fn,
resultSelector: {
lambdaOutput: sfn.JsonPath.stringAt('$.Payload'),
invokeRequestId: sfn.JsonPath.stringAt('$.SdkResponseMetadata.RequestId'),
staticValue: {
foo: 'bar',
},
stateName: sfn.JsonPath.stringAt('$$.State.Name'),
},
});
Properties
Name | Type | Description |
---|---|---|
static DISCARD | string | Special string value to discard state input, output or result. |
static entire | string | Use the entire context data structure. |
static entire | string | Use the entire data structure. |
static task | string | Return the Task Token field. |
static DISCARD
Type:
string
Special string value to discard state input, output or result.
static entireContext
Type:
string
Use the entire context data structure.
Will be an object at invocation time, but is represented in the CDK application as a string.
static entirePayload
Type:
string
Use the entire data structure.
Will be an object at invocation time, but is represented in the CDK application as a string.
static taskToken
Type:
string
Return the Task Token field.
External actions will need this token to report step completion
back to StepFunctions using the SendTaskSuccess
or SendTaskFailure
calls.
Methods
Name | Description |
---|---|
static array(...values) | Make an intrinsic States.Array expression. |
static format(formatString, ...values) | Make an intrinsic States.Format expression. |
static is | Determines if the indicated string is an encoded JSON path. |
static json | Make an intrinsic States.JsonToString expression. |
static list | Instead of using a literal string list, get the value from a JSON path. |
static number | Instead of using a literal number, get the value from a JSON path. |
static object | Reference a complete (complex) object in a JSON path location. |
static string | Instead of using a literal string, get the value from a JSON path. |
static string | Make an intrinsic States.StringToJson expression. |
static array(...values)
public static array(...values: string[]): string
Parameters
- values
string
Returns
string
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.
static format(formatString, ...values)
public static format(formatString: string, ...values: string[]): string
Parameters
- formatString
string
- values
string
Returns
string
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.stringAt('$.name'))
static isEncodedJsonPath(value)
public static isEncodedJsonPath(value: string): boolean
Parameters
- value
string
— string to be evaluated.
Returns
boolean
Determines if the indicated string is an encoded JSON path.
static jsonToString(value)
public static jsonToString(value: any): string
Parameters
- value
any
Returns
string
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.jsonToString(sfn.JsonPath.objectAt('$.someObject'))
static listAt(path)
public static listAt(path: string): string[]
Parameters
- path
string
Returns
string[]
Instead of using a literal string list, get the value from a JSON path.
static numberAt(path)
public static numberAt(path: string): number
Parameters
- path
string
Returns
number
Instead of using a literal number, get the value from a JSON path.
static objectAt(path)
public static objectAt(path: string): IResolvable
Parameters
- path
string
Returns
Reference a complete (complex) object in a JSON path location.
static stringAt(path)
public static stringAt(path: string): string
Parameters
- path
string
Returns
string
Instead of using a literal string, get the value from a JSON path.
static stringToJson(jsonString)
public static stringToJson(jsonString: string): IResolvable
Parameters
- jsonString
string
Returns
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.stringToJson(sfn.JsonPath.stringAt('$.someJsonBody'))