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

An exception occurred when sending a string with double quotes #3504

Closed
2 tasks
Cdreamfly opened this issue May 20, 2022 · 3 comments
Closed
2 tasks

An exception occurred when sending a string with double quotes #3504

Cdreamfly opened this issue May 20, 2022 · 3 comments
Labels
solution: invalid the issue is not related to the library

Comments

@Cdreamfly
Copy link

Description

An exception occurred when sending a string with double quotes

Reproduction steps

If I send a string with double quotes, it will not parse properly, for example, if I type "hello".

Expected vs. actual results

After a json "msg":""hello""

Minimal code example

No response

Error messages

terminate called after throwing an instance of 'nlohmann::detail::parse_error'
  what():  [json.exception.parse_error.101] parse error at line 1, column 17: syntax error while parsing object - invalid literal; last read: '""o'; expected '}'

Compiler and operating system

gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)

Library version

JSON for Modern C++ version 3.10.5

Validation

@nlohmann
Copy link
Owner

Quotes must be escaped in JSON strings. This is valid JSON:

{
    "msg": "\"hello\""
}

This is not:

{
    "msg": ""hello""
}

@nlohmann nlohmann added solution: invalid the issue is not related to the library and removed kind: bug labels May 20, 2022
@Cdreamfly
Copy link
Author

Oh, yes, thank you for your answer, I should have thought carefully before asking.

@nlohmann
Copy link
Owner

No worries!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: invalid the issue is not related to the library
Projects
None yet
Development

No branches or pull requests

2 participants