[Solved] How can I separate a string and make a new line


Hi guys! I need help. I have this JSON output:


{“text”:“Title:Land\nBody:Dog\n\nTitle:Air\nBody:Bird\n\nTitle:Water\nBody:Fish\n\n”}


For now, blip bot gives me this output:


Title:Land\nBody:Dog\n\nTitle:Air\nBody:Bird\n\nTitle:Water\nBody:Fish\n\n


But I wanted the bot to achieve this output:


Title:Land

Body:Dog


Title:Air

Body:Bird


Title:Water

Body:Fish


I was using Integromat to get JSON API.


How can you make /n as new line in blip?


5 comentários

Hi @Erika_Anne_Baravio,


unfortunantly, if you use a variable like {{yourJson@text}} BLiP will not understand the special characters.

In order to change this behavior you must use an Execute Script action that just return the string with ‘\n’ characters.


Look a sample below:



Note that the Execute Script action returns a new variable with name {{test}}.



When you use it, you will see the string exactly as you want.


Hi Rafael. Thanks so much for the help. 🙂 But what if the json output came from a url?

But there seems to be a problem with my code. Since I’m getting the json output from a url.


Here’s my set up.

@Erika_Anne_Baravio,


you are using the script in a wrong way.

You can’t use displayMenu variable inside of the script. This variable will receive the return of your script.


So basically, your script must be:


function run(menu){
menu = JSON.parse(menu);
return menu.text;
}

That solves my problem. I was trying that code yesterday. Idk what happened. 🙂

Comente