Best answer

Get nested JSON objects and format side by side

  • 12 May 2021
  • 3 replies

Userlevel 1

Hey guys, 

New to Zapier, trying to get two JSON items and format them so they’re side by side. I’m using a Catch hook Webhooks by Zapier, and I’m getting all data correctly, like selectable via the “Insert data” drop down and picking the right parts, but I have the following JSON:

"subject": "test subject",
"first_name": "test",
"last_name": "test",
"email": "",
"phone": "123456789",
"Message": {
"parts": [
"part_number": "ABC-001",
"qty": 1
"part_number": "ABC-002",
"qty": 2
"notes": "This is a test note!"

I want to put the part_number and qty in this format in a Message that will be sent/emailed:

Part number: ABC-001 Qty: 1

Part number: ABC-002 Qty: 2

So I want the part number and quantity to be side by side, at the moment I’m getting the part number, and then underneath the quantities, all comma separated, like so:

ABC-001, ABC-002

1, 2

Obviously this would get confusing if lots of items were there, so looking to format it like the above, I’m guessing I’ll need to format it via Code by Zapier, just not sure how to access the data? or how the fields work on Code by Zapier, I take it the left field is for the variable name and then the right field is where we select what data we want? Then how to output it right for however many elements are there, some kind of loop of course but not sure the best way, or can I just format it straight in the output Message field (Create lead for Quotient) somehow? 

Thanks in advance! 


Best answer by GetUWired 13 May 2021, 14:49

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

Userlevel 7
Badge +14

Hi @sam.collins 

Here’s the help articles related to Code by Zapier:


I suggest doing some GSearches on your topic as there are plenty of code examples out there to copy and edit.

Also, W3 is a great resource with examples:


Another option is to use Looping and Digest actions.



Userlevel 7
Badge +12

Hi @sam.collins 

To help you move along. You can do this with a simple for loop. Please see below. 

let parts = inputData.part.split(",");
let qtys = inputData.qty.split(",");

var output = [];
for (var j=0;j<qtys.length;j++) {
let temp = "";
temp = `Part Number: ${parts[j]} Qty: ${qtys[j]}`

return {output};


Userlevel 1

@GetUWired Yes that's done the trick, perfect! Thank you so much!