Json: Allow multiple line string value in JSON

Created on 10 Jan 2020  路  2Comments  路  Source: nlohmann/json

Hello,

I tried to parse a specific JSON that contain a string value set on 4 lines (vertexShader) :

{
"vertexShader" : "
     void main(void)
     {
         gl_Position = vec4(1.0);
     }
",
"fragmentShader" : "void main(void){gl_FragColor = vec4(1.0);}"
}

It's perfectly working if i'm in the fragmentShader case but an error occur : C++ exception with description "[json.exception.parse_error.101] parse error, syntax error while parsing value - invalid string: control character U+000A (LF) must be escaped to \u000A or \n; last read: '"<U+000A>'" thrown in the test body. when i try to parse a json looking like vertexShader, i'm using the templated method get(), get() .

Does any function in the existing library allow this ?

System : Linux, Fedora 29

question

Most helpful comment

I'm afraid there is no function to fix this as newlines must be escaped in JSON, see

All 2 comments

I'm afraid there is no function to fix this as newlines must be escaped in JSON, see

Thank you for the answer was very helpful :)

Was this page helpful?
0 / 5 - 0 ratings