• Instructions to Ask a Question

    Click on the "Ask a Question" button and select the application for which you would like to ask questions.

    We have 5 different products namely - Pabbly Connect, Pabbly Subscription Billing, Pabbly Email Marketing, Pabbly Form Builder, Pabbly Email Verification.

    The turnaround time is 24 hrs (Business Hours - 10.00 AM to 6.00 PM IST, Except Saturday and Sunday). So your kind patience will be highly appreciated!

    🚀🚀Exclusive Discount Offer

    Just in case you're looking for any ongoing offers on Pabbly, you can check the one-time offers listed below. You just need to pay once and use the application forever -
     

    🔥 Pabbly Connect One Time Plan for $249 (🏆Lifetime Access) -  View offer 

    🔥 Pabbly Subscription Billing One Time Plan for $249 (🏆Lifetime Access) - View offer

Chain json results as string

phil

Member
A module return a json payload with a X number of results, like

values > 0 > 0 Apple
values > 1 > 0 Orange
values > 2 > 0 Pear

and I need to generate a multi-line string like

Apple
Orange
Pear

Which is the best way?
 

Neeraj

Administrator
Staff member
A module return a json payload with a X number of results, like

values > 0 > 0 Apple
values > 1 > 0 Orange
values > 2 > 0 Pear

and I need to generate a multi-line string like

Apple
Orange
Pear

Which is the best way?
Do you have fix amount of results every time or do they keep on changing?
 

Neeraj

Administrator
Staff member
Keep changing, otherwise it would be easy ;)
Can you change your incoming payload from the source?

Add a new key will All the values in it?

Otherwise, I am out of ideas. Maybe someone else can pitch in.
 
P

PabblyMember3

Guest
A module return a json payload with a X number of results, like

values > 0 > 0 Apple
values > 1 > 0 Orange
values > 2 > 0 Pear

and I need to generate a multi-line string like

Apple
Orange
Pear

Which is the best way?
Can you try to get the above data not as a simplified response and then, pass the value array to JSON extractor to get the values as shown below:

jsonex.png

And then you can replace comma from the data > all with <br> in the next step using Text Formatter - Replace Text action to get the desired values.
 

phil

Member
Yes it's troublesome.
Please consider adding a variable module in PC, that allows iterations.
That would make operation more simple and wouldn't need multiple steps.

This would be easy like

foreach ($module_result as $value) {
$value = $value & "\n";
}
return $value


I will check the Naveen solution
 
P

PabblyMember3

Guest
In my case Naveer solutionwon't work.
I get the values from the Google Sheet module


so I cannot use the Json extractor to get all values
Hey Phil,

Just turn of the simple response and send the test request in the Google Sheet step, you will get the values as an array and map the same in the JSON extractor field, you will get the response with comma separated values
 
P

PabblyMember3

Guest
I have created a simpler one, for you to test

Thanks for sharing the workflow.

I can see, there are nested square brackets causing the problem, but, I have made some changes to make it work.

I have added a couple of Text Formatters - Replace Text to replace [" and "] with " (double quotes) to get the final array like ["val1","val2"].

Please check the attachment and your workflow. Now, you can get the comma separated values.

I hope you find it helpful.
 

Attachments

  • jsonex1.png
    jsonex1.png
    56.8 KB · Views: 107

phil

Member
Thanks for your help, Naveen.
That's the same solution I am using in my workflow, but doesn't look a bit....weird?
Especially when you have different logical mappings, it looks like a maze in a jungle ;)
A text filter, that allows only certain characters to go trough (ex. A-Z, 0-9), would be a great help.
Not perfect, but "clean", at least.
 

phil

Member
By the way, if you use multiple Text Replace module, you won't even need the json extractor.
Simply replace all ", [ and ] and you get a value1,value2 string
 
P

PabblyMember3

Guest
By the way, if you use multiple Text Replace module, you won't even need the json extractor.
Simply replace all ", [ and ] and you get a value1,value2 string
I can understand, unfortunately, multiple replacements in a single step are not possible. For now, you can use the Text Replace step one by one for doing the same.
 
Last edited by a moderator:
Top