Remove one layer on JSON nesting

Hi there!

I'm trying to remove a layer of nesting from a POST query, which i think I need to acheive using a transformer - but I've sadly not used them before and am a bit lost..

I'm currently returning :

{
  "channel": "scene",
  "actualChannel": null,
  "subscribedChannel": "scene",
  "timetoken": "16877728652054544",
  "publisher": "retoolAdmin",
  "message": {
    "message": "AnotherGame"
  }
}

and I need to return

{
  "channel": "scene",
  "actualChannel": null,
  "subscribedChannel": "scene",
  "timetoken": "16877728652054544",
  "publisher": "retoolAdmin",
   "message": "AnotherGame"
  
}

If anyone could help me with how to approach this, I'd be HUGELY grateful!

Thanks

You could merge it into itself.

{{ _.merge(query.data, query.data.message) }}

Not very robust if the message is an array or you want to use multiple objects though

1 Like