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

Occur error when parse character '\' #3844

Closed
2 tasks
AronZhi opened this issue Nov 22, 2022 · 5 comments
Closed
2 tasks

Occur error when parse character '\' #3844

AronZhi opened this issue Nov 22, 2022 · 5 comments
Labels
solution: invalid the issue is not related to the library

Comments

@AronZhi
Copy link

AronZhi commented Nov 22, 2022

Description

When I run code as follows:

    std::string sData("{\"a\":\"b\\a\",\"b\":2}");
    nlohmann::json obj = nlohmann::json::parse(sData);

It both throw error in version 3.7.3 and 3.11.2.

After delete '' as follows:

    std::string sData("{\"a\":\"ba\",\"b\":2}");
    nlohmann::json obj = nlohmann::json::parse(sData);

It will run successfuly.

Reproduction steps

Run code as follows:

    std::string sData("{\"a\":\"b\\a\",\"b\":2}");
    nlohmann::json obj = nlohmann::json::parse(sData);

It both throw error in version 3.7.3 and 3.11.2.

Expected vs. actual results

expect:
json::parse run success and no error occur.

actually:
error occur

Minimal code example

No response

Error messages

No response

Compiler and operating system

Microsoft Visual C++ 2019 / Build Tools 16.3.1+1def00d3d (and possibly later)

Library version

3.11.2 or 3.7.3

Validation

@nlohmann
Copy link
Owner

The exception message should tell you that backslashes need to be escaped.

@nlohmann nlohmann added solution: invalid the issue is not related to the library and removed kind: bug labels Nov 22, 2022
@AronZhi
Copy link
Author

AronZhi commented Nov 23, 2022

The code in reproduction steps section, I did escaped the backslashes, but Git don't show the original code.

@AronZhi
Copy link
Author

AronZhi commented Nov 23, 2022

When processing a string containing a windows format path, an unhandled exception will be thrown

@AronZhi
Copy link
Author

AronZhi commented Nov 23, 2022

This issue is same as issue #2652

@gregmarr
Copy link
Contributor

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

3 participants