How to include an unparsed dictionary list in Zapier JSON output?

Hey folks, I’m stuck with a Zapier issue. I’ve got a Code Step that creates an array of managers and members from a form trigger. It works fine, but I’m having trouble getting it into my JSON for a webhook.

The array looks something like this:

"staff": [
   {
      "name": "Jane Doe",
      "role": "Manager",
      "contact": "[email protected]",
      "location": "123 Office Rd, Worktown 12345"
   },
   {
      "name": "John Smith",
      "role": "Member",
      "contact": "[email protected]",
      "location": "456 Work St, Jobcity 67890"
   }
]

I want to put this whole thing into my JSON, but Zapier is breaking it up into separate variables. How can I keep it as one block and insert it into my JSON? Any ideas?

hey oscar64, i’ve run into this before. try using JSON.stringify() on ur staff array before putting it in the webhook. like this:

jsonOutput = {
…otherStuff,
staff: JSON.stringify(staffArray)
}

that should keep it as one chunk. lmk if it works!

I encountered a similar issue in one of my Zapier workflows. The solution that worked for me was to use a Formatter step before the webhook. Set it to ‘Text’ mode and use the ‘Code Mode’ option. Then, you can construct your entire JSON object as a string, including your staff array.

Here’s a basic example of what the code might look like:

output = JSON.stringify({
  otherData: input.otherData,
  staff: input.staffArray
});

This approach allows you to maintain the structure of your staff array within the larger JSON object. In the webhook step, you can then use the output from this Formatter step as the body of your request. This method preserves the integrity of your nested data structures.