Question

Create line items based on nested key value pairs

  • 2 May 2023
  • 3 replies
  • 181 views


Hello Zapier community, 

I am desperately looking for a solution for the following. We are obtaining data from a webhook that gives us an array. Most of the data can be easily mapped in following tags, however there a couple of key value pairs that we are able to map.

The test data is showing us lead data and every specific lead has its om leadID. Under which we come across “extrainfoJson” which holds quite a number of key value pairs. To many unfortunately so that the file size becomes to large. Therefore we have looking into javascript in order to map the values. 

 

What I have came up with so far is: 


output = [{
    "leadID": "leadID",
    "Naam": "Opmerkingen",
    "Key": "Inhoud",
    "Value": "Gegevens aangeboden voertuig",
    "line_items" : [
        {  
            "leadID": "leadID",
            "Naam": "Opmerkingen",
            "Key": "Inhoud",
            "Value": "Gegevens aangeboden voertuig"
        }
    ]
}
]
 

I also tried line items into text but that won't do it with the key value pairs.

 


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 +8

Hi @CRC 

 

Can you please share more details as to what exactly you are trying to achieve? 

 

For example, Looping by Zapier can loop through the values if you are trying to trigger actions for each Pair. 

 

IF this is not what you are trying to do, how about creating a loop in Code by Zapier that manages these values? 

 

This all depends on what you are trying to do

Thanks for your help @MohSwellam!

We are filling out a Google Spreadsheet. So what I try to achieve here is that I would like to add the values from the key value pair to a specific column in a Google spreadsheet. We are already creating new rows with all the fields that we can access. In this image you can see that we are setting a value from step 2 in our setup. As we update multi leads at once, they are comma seperated which is perfect.

We would like to do the same with the key value pairs and output them in another variable in the spreadsheet.

 

 

Userlevel 7
Badge +8

Hi @CRC 

 

If I understand you correctly, you want all the “keys” (for example) in one field, correct? 

 

In this case you can use a Code by Zapier step to loop through the values and create a comma separated string