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

[json.exception.parse_error.101] parse error at line 1, column 4520: syntax error while parsing value - invalid string: forbidden character after backslash; last read: '".\? #4352

Closed
2 tasks done
181404010226 opened this issue Apr 19, 2024 · 2 comments
Labels
solution: invalid the issue is not related to the library

Comments

@181404010226
Copy link

Description

I encountered an error while trying to load the JSON shown below. The error occurred at the position highlighted in blue.
image
The json file:
tileset.json
This is a 3D Tiles project where I convert strings to UTF-8 to ensure JSON exports correctly. Without this conversion, I encounter an error labeled "invalid UTF-8 byte at index." The image below shows the problematic string in debug mode.
image

Reproduction steps

when load the json file it happened.

Expected vs. actual results

I expected it successed loaded.

Minimal code example

json childJson;  
try {
    file >> childJson;
}
catch (const json::parse_error& e) {
    std::cerr << "\033[1;31mERROR!\033[0m JSON parse error in file " << entry.path() << ": " << e.what() << std::endl;
    file.close();
    return; // 中断程序
}
file.close();

Error messages

ERROR! JSON parse error in file "C:\\Users\\Administrator\\Desktop\\Data\\temp\\开元通宝及广场\\tileset.json": [json.exception.parse_error.101] parse error at line 1, column 4520: syntax error while parsing value - invalid string: forbidden character after backslash; last read: '".\?

Compiler and operating system

Microsoft Visual C++ 2022,windows10

Library version

3.10.4

Validation

@Nevermore1994
Copy link

Nevermore1994 commented Apr 19, 2024

I think the string ".\开元通宝及广场" itself does not comply with the JSON specification. When exported, it should be ".\\开元通宝及广场" to comply with the specification.

@nlohmann
Copy link
Owner

The error message states the reason: after a backslash, only a few characters are allowed:

@nlohmann nlohmann added solution: invalid the issue is not related to the library and removed kind: bug labels Apr 19, 2024
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