How to code long JSON value strings as multiline?

json, multiline, string

Solution

You can use multiple lines string representation in JavaScript:

JSON.parse('{"a" : "a\
asd"}')

Tried in console. It works.

Problem

IMPORTANT: I am not asking about rendering strings as multiline. I am talking about splitting a long string in a JSON into multiple lines in my source code when this string should logically be on a single line. In short: I want source line breaking rules similar to HTML. ``` { "id": 550, "text": "this is long text " "very-very-very long text " "longer than you can imagine." } ``` This text should be rendered as: ``` this is long text very-very-very long text longer than you can imagine. ``` The JSON is being referenced in JavaScript. This is not a duplicate of Multiline strings in JSON because this question strongly refers to JavaScript and that question has no clear accepted answer.

Original source

Related problems