Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple line string value in JSON #1897

Closed
PixDay opened this issue Jan 10, 2020 · 2 comments
Closed

Allow multiple line string value in JSON #1897

PixDay opened this issue Jan 10, 2020 · 2 comments

Comments

@PixDay
Copy link

PixDay commented Jan 10, 2020

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(), getstd::string() .

Does any function in the existing library allow this ?

System : Linux, Fedora 29

@nlohmann
Copy link
Owner

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

@PixDay
Copy link
Author

PixDay commented Jan 10, 2020

Thank you for the answer was very helpful :)

@PixDay PixDay closed this as completed Jan 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants