Json line break question

I’m working with some json in a looper.
One of my fields looks like this:

"hostDetails": "No default text\n- list 1\n- list 2\n\nWe like to have line breaks",

If I just call the field, {{dc:looper:field key="data.hostDetails"}} then it outputs a single block of text without the \n characters.
If I add in {{dc:looper:field key="data.hostDetails" type="json" pretty_print="1"}} It outputs the \n on the page. (It does that without the pretty_print as well.)

Is there a built in way to get it to translate those line break characters, or should I get with the folks giving me the json for another way?

Hello @GL_creative,

Thanks for writing in!

Why type="json" doesn’t work :
Adding type="json" only escapes the string for JSON-safe output. It prints the literal characters \ and n on the page instead of rendering them as line breaks, so it doesn’t solve your formatting issue.

To get around this, we will have it this way:

  • Output the text using “{{dc:looper:field key=“data.hostDetails”}}” to display the raw text
  • Add this custom inline CSS to the Text element:
$el {
    white-space: pre-wrap;
}

Kindly let us know how it goes.