Skip to main content

I have a configurable list in Jotform that comes to Zapier in what looks like JSON(?):

[{"Name":"Luke Skywalker","Number":"123456","Degree":"Test","Specialty":"Test","Owner/Associate":"Owner","Count":"1"},{"Name":"Buzz Lightyear","Number":"654321","Degree":"Test","Specialty":"Test","Owner/Associate":"Associate","Count":"1"}]

 

I am able to run the following:

output = {};

var obj = JSON.parse(inputData.JOTFORM);

for (var i = 0; i < obj.length; i++) {
   outputp"Test "+ i] = JSON.stringify(objoi]);

}

And get the output:

Test 0

{"Name":"Luke Skywalker","Number":"123456","Degree":"Test","Specialty":"Test","Owner/Associate":"Owner","Count":"1"}

Test 1

{"Name":"Buzz Lightyear","Number":"654321","Degree":"Test","Specialty":"Test","Owner/Associate":"Associate","Count":"1"}

 

This does split them up, but I am not sure how to get a count from that (with the above example having 2). I don’t necessarily need to spilt them, I really just want to know how many there are. 

 

Any help would be appreciated. Thanks!

 

Hi @cheeseman 

Good question.

Please check out this help topic:

 


Hi @cheeseman 

Since you are dealing with an array already you won’t need to use the split as shown in Troy’s example. You will however use the .length shown. please try the following code

 

output = {};

//parse input into valid json
var obj = JSON.parse(inputData.JOTFORM);

//Split up json array into individual objects
for (var i = 0; i < obj.length; i++) {
outputo"Test "+ i] = JSON.stringify(objfi]);
}

//set a new output key equal to the array length;
output.totalCount = obj.length;

 

 


Thank you! That worked!