amazon web services - AWS Step Function JSONata how to combine input and result from task - Stack Overflow

admin2025-04-15  3

When using JSONPath, I knew how to combine input to some task(for instance lambda) and just add the result to additional property. For instance:

{
 "input_1" : "value_1",
 "input_2" : "value_2
}

and after invoking lambda function, I would get(using ResultPath):

{
 "input_1" : "value_1",
 "input_2" : "value_2,
 "lambda_result" : "value_3"
}

How can I achieve this using JSONata?

When using JSONPath, I knew how to combine input to some task(for instance lambda) and just add the result to additional property. For instance:

{
 "input_1" : "value_1",
 "input_2" : "value_2
}

and after invoking lambda function, I would get(using ResultPath):

{
 "input_1" : "value_1",
 "input_2" : "value_2,
 "lambda_result" : "value_3"
}

How can I achieve this using JSONata?

Share Improve this question asked Feb 4 at 10:58 datahackdatahack 6492 gold badges16 silver badges38 bronze badges 2
  • Are you combining numbers, strings or objects? Please can you add more details to your question? – Vlad Dimov Commented Feb 4 at 20:21
  • Combining just strings. – datahack Commented Feb 5 at 7:04
Add a comment  | 

1 Answer 1

Reset to default 3

With JSONata in Step Functions, the Output must contain all required properties explicitly. You can achieve this with a JSONata $merge:

{%
    $merge([$states.input, {
      "lambda_result": $states.result.Payload
    }])
%}
转载请注明原文地址:http://anycun.com/QandA/1744724993a86750.html