Support line feeds in json JSON {}

0 votes
asked Mar 28 in Wanted features by boshka (3,940 points)

Could json JSON support linefeeds:

json JSON {
  "text": "Line 1\nLine 2\nLine 3"
}

(and probably other control symbols, like \t, etc.)?

Related comment https://forum.plantuml.net/16639/long-text-in-json?show=18804#c18804

commented Mar 28 by The-Lu (64,960 points)

[Just for the record]
See also pseudo-similar issue here:

1 Answer

0 votes
answered Apr 1 by kirchsth (5,780 points)

Hi @boshka,

Json objects have an additional escape step (with same character \) therefore you have to escape \ with \\ itself.
This means you need e.g. \\n for a line break (details: see JSON two-character escape sequence​).



BR Helmut  

commented Apr 2 by The-Lu (64,960 points)

Yes, but that is a bug...
As mentioned on the end of:

commented Apr 2 by kirchsth (5,780 points)

It looks like that PlantUML "supports" (or is inconsistent) both version.
If it is defined via variables then you could use the version with one backslash, and in text you need 2 backslashes.



But if the grammar changes from "2 backslashes" to "one backslash" then a new notation would be required otherwise compatibility is lost.

...