Error on parsing json with new line character

Viewed 162

I trying to use retrofit on flutter & I am using json_serializable to serialize.

In JSON I have:

{
  "date": "07.12.2020",
  "header": "Test header",
  "text": "line one 
line two,
line 3"
    }

With new line chars inline. The new lines on "text" part

Because of these new line chars, I have an error by parsing

unexpected character on line...

But the same JSON successfully parsed on android.

Are any ways to replace or solve this problem?

1 Answers

Multi-line text is not allowed in JSON. You need to convert new lines using \n. Then you can parse it easily.

Related