Are multi-line strings allowed in JSON?

前端 未结 9 1459
醉酒成梦
醉酒成梦 2020-11-22 04:21

Is it possible to have multi-line strings in JSON?

It\'s mostly for visual comfort so I suppose I can just turn word wrap on in my editor, but I\'m just kinda curious

9条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 04:32

    Write property value as a array of strings. Like example given over here https://gun.io/blog/multi-line-strings-in-json/. This will help.

    We can always use array of strings for multiline strings like following.

    {
        "singleLine": "Some singleline String",
        "multiline": ["Line one", "line Two", "Line Three"]
    } 
    

    And we can easily iterate array to display content in multi line fashion.

提交回复
热议问题