Join Array with a new line?

Options
Hey there! 

I'm trying to build .ics files inside Xano from scratch and what I'm doing is depending on inputs, conditionally adding variables to an array. One might be if it's virtual, there's a location, etc. 

At the end though, when it's time to build the file,l I need to take all the "lines" or values of the array and create one large variable with all it's contents, however, there needs to be a new line between each variable. 

Is this possible?

Comments

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options
    Here's a screenshot that shows how you accomplish it. You get your lines into an array of strings. Then you use the join function to connect them. Since Xano doesn't handle unescaping, you connect with the escaped newline character (e.g. backslash-n). You apply a nested filter with json_decode to unescape it into an actual newline character. Voila - newline-delimited text. It'll look wrong on the run-and-debug output, but if you copy and paste into notepad or the like, you can confirm the correctness of the result.

    [image.png]
  • Unknown
    Options
     Wow thanks, I'll give this a shot!! I was trying join with \n but I'll try the json decode 🙂 Thanks! 
  • Unknown
    Options
    Ahh dang this doesn't work 
    Exception: Error parsing JSON: Syntax error \n
  • Unknown
    Options
     Update: I missed the requirements for quotes, now this seems to work! Thanks I'll do some digging and text further to make it work. Appreciate it!