Can a JSON value contain a multiline string

前端 未结 5 1295
粉色の甜心
粉色の甜心 2020-12-13 16:43

I am writing a JSON file which would be read by a Java program. The fragment is as follows...

{
  \"testCases\" :
  {
    \"case.1\" :
    {
      \"scenario         


        
5条回答
  •  渐次进展
    2020-12-13 17:11

    I'm not sure of your exact requirement but one possible solution to improve 'readability' is to store it as an array.

    {
      "testCases" :
      {
        "case.1" :
        {
          "scenario" : "this the case 1.",
          "result" : ["this is a very long line which is not easily readble.",
                      "so i would like to write it in multiple lines.",
                      "but, i do NOT require any new lines in the output."]
        }
      }
    }
    
    }
    

    The join in back again whenever required with

    result.join(" ")
    

提交回复
热议问题