0
votes

I have an AWS step function as follows -

{
  "StartAt": "S1",
  "States": {
    "S1": {
      "Type": "Pass",
      "Parameters": {
        "Fruits.$": "$.Junk.Fruits"
      },
      "ResultPath": "$.Main.Fruits",
      "Next": "S2"
     
    },
    "S2": {
    "Type": "Pass",
    "OutputPath": "$.Main",
    "End": true
  }
  }
}

My input is as follows-

{
    "Main": {
        "Field": "field",
        "Field2": "field2",
        "Fruits":[]
    },
    "Junk": {
        "Fruits":["apple", "banana", "papaya", "grapes"]
    }
}

The output I obtain is as follows-

{
  "Field": "field",
  "Field2": "field2",
  "Fruits": {
    "Fruits": [
      "apple",
      "banana",
      "papaya",
      "grapes"
    ]
  }
}

The output I want is as follows -

{
    "Field": "field",
    "Field2": "field2",
    "Fruits": [ "apple", "banana", "papaya", "grapes" ]
}

Can you please rectify the step function so that I get the output I want. Please don't use lambda functions and please don't modify the input.

1

1 Answers

1
votes

You can acheive the output you want by using Parameters like this:

{
  "StartAt": "S1",
  "States": {
    "S1": {
      "Type": "Pass",
      "Parameters": {
        "Field.$": "$.Main.Field",
        "Field2.$": "$.Main.Field2",
        "Fruits.$": "$.Junk.Fruits"
      },
      "End": true
    }
  }
}

But if you are looking for merging two JSON object (without knowing the keys) I'm afraid that AWS Step Functions doesn't support it yet.