-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Internal structure gets corrupted while parsing #569
Comments
The library fully supports UTF-8, and I can parse the file without problems: #include "json.hpp"
#include <fstream>
using json = nlohmann::json;
int main()
{
std::ifstream f("settings.json");
json j = json::parse(f);
std::cout << std::setw(2) << j << std::endl;
} output: {
"Pixhawk": {
"LocalHostIp": "127.0.0.1",
"LogViewerHostIp": "127.0.0.1",
"LogViewerPort": 14388,
"Model": "Flamewheel",
"OffboardCompID": 1,
"OffboardSysID": 134,
"QgcHostIp": "127.0.0.1",
"QgcPort": 14550,
"SerialBaudRate": 115200,
"SerialPort": "*",
"SimCompID": 42,
"SimSysID": 142,
"SitlIp": "127.0.0.1",
"SitlPort": 14556,
"UdpIp": "127.0.0.1",
"UdpPort": 14560,
"UseSerial": true,
"VehicleCompID": 1,
"VehicleSysID": 135
},
"RpcEnabled": false
} The file does not contain any non-ASCII byte. Can you provide more information? |
I'm not able to reproduce this now so closing the issue. If I see this again, I'll re-open. |
Ok. Thanks for checking back! |
Hello, guys! Got exactly the same issue :) |
Spent an hour :) |
OMG... json jsonObj{ json_t::parse("{"x": "y"}") }; - works fine on Windows with latest VS2017 Looks like different compilers chose different (copy?)constructors or something like that around initializer's list. Just WOW! |
I'll have a look. |
Thank you! BTW: Amazing lib! ;) |
|
gcc has had problems with the unified initializer construct. Although I thought that with version 7, it properly handled most of the legal constructs that clang/llvm and MSVS have been able to handle for years. Also for the fun of it, is there any difference when you specifically use g++ instead of gcc for the command line? I know that there are cases where clang will do something a little differently than clang++. |
I can confirm that Clang and GCC (I tried version 5 to 8) behave differently when it comes to these lines: json j1{ json::parse("{\"x\": \"y\"}") };
json j2 = json::parse("{\"x\": \"y\"}"); In all cases, I think there is nothing I can do from the library side. |
I've two json files. One is stored using ASCII encoding and other is stored using UTF-8 encoding without BOM (using Notepad++'s encoding feature). When I load the UTF-8 file using json.hpp, its internal structure looks corrupted (very large array sizes) and you will see crash trying to read any of elements. The ASCII encoding seems to work fine. However the thing is that there are non-ASCII chars in the content.
Attached is the very small json file I'm trying to read.
settings.zip
The text was updated successfully, but these errors were encountered: