AWS Step Function JsonMerge new data

58 Views Asked by At

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?

1

There are 1 best solutions below

1
fedonev On

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)"
}