Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Step Function JsonMerge new data

The intrinsic function States.JsonMerge works to add a new, static json in the data simulator. So this works in the Parameters in the data simulator to add the newKey to all the incoming input of the state:

{
  "input.$": "States.JsonMerge($, { \"newKey\": 1 }, false)"
}

enter image description here

However, in an actual State Machine definition, it rejects that.

enter image description here

At the least, this seems to show an issue with either the data simulator or the state machine definition rules.

The question is there a way to do such an operation of adding a new "hard coded" json object like the data simulator allows and format it correctly for the state machine?

like image 873
ScottS Avatar asked Oct 30 '25 09:10

ScottS


1 Answers

Add a hardcoded key and hardcoded value to the input:

{
  "input.$": "States.JsonMerge($, States.StringToJson('{\"newkey\":1}'), false)"
}

Add a hardcoded key and a *substituted* value to the input:

{
  "input.$": "States.JsonMerge($, States.StringToJson(States.Format('\\{\"newkey\":\"{}\"\\}', $.myValue)), false)"
}
like image 144
fedonev Avatar answered Nov 01 '25 12:11

fedonev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!