How do you promote/spread/splat a nested JSON object to be top level in AWS Pipe Tranformation

  Kiến thức lập trình

Say I have an input event that looks like this:

{
  nested: {
    what: "ever"
  },
  not_nested: "dontcare"
}

How could I use a transformation filter in an AWS EventBridge Pipe that would “promote” the nested properties under the nested key to top level, merging them with specific properties already at the top level, resulting in the following:

{
  what: "ever"
  not_nested: "dontcare"
}

IMPORTANT NOTE: I do not know the structure of the nested object. I therefore can NOT target specific nested properties for inclusion in the resulting object — I need to target “all children” of the nested object. In typescript, the code would be something like this:

const result = {
  ...event.nested,
  not_nested: event.not_nested
}

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website Kho Theme wordpress Kho Theme WP Theme WP

LEAVE A COMMENT