-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
'\' char problem in strings #261
Comments
On first sight, there are too many backslashes: there should be two instead of three, because {
"window": {
"texture": "interface\\ifcommon\\slibifwnd.ddj",
"width": 330,
"height": 366,
"position": [0, 0],
"rect": [0, 0, 330, 366],
"moveable": true,
"moverect": [0, 0, 330, 30]
}
} |
Can you then please paste the complete JSON as is? The current one begins with |
|
Thanks. This file is valid JSON, and I can parse it without problems with #include <json.hpp>
#include <fstream>
using nlohmann::json;
int main()
{
// just parse the string
json s = R"("interface\\ifcommon\\slibifwnd.ddj")"_json;
std::cout << std::setw(2) << s << std::endl;
// parse the whole file
std::ifstream f("issue261.json");
json j;
j << f;
std::cout << std::setw(2) << j << std::endl;
} Could you please try this code? Especially, parsing just the string would be interesting. |
And just to make sure:
|
I figured out the problem; there is no problem when I use R prefix
but the problem is backslashes, json required format: |
I am trying to parse this json:
"window": {
"texture": "interface\ifcommon\slibifwnd.ddj",
"width":330,
"height":366,
"position": [0, 0],
"rect": [0, 0, 330, 366],
"moveable": true,
"moverect": [0, 0, 330, 30]
},
but parser gives me unexpected \ error for string.
IDE: Visual Studio 2015
The text was updated successfully, but these errors were encountered: