1

I have a text and would like to break lines in it, the format is application / json.

I used /n but sometimes it seems to work, and other no.

{"Text":"# hi  \n\n::: red \n\nImportant  \n bye"}

Thanks

1
  • "sometimes it seems to work, and other no.": What does this mean? Apr 16, 2019 at 12:30

1 Answer 1

1

Use \ for escape character before \n :

{"Text":"# hi  \\n\\n::: red \\n\\nImportant  \\n bye"}
2
  • Thanks. One questions. Do have any chance of the encode remove the line breaks of this string?
    – Sabrina B.
    Apr 16, 2019 at 14:02
  • I think different encoding will affect the line break, another way is that you can use any json parser to parse the json and then add new line into the json, in this way no encoding issue will occur. Apr 16, 2019 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.