Closed dodiak closed 1 month ago
The example code does not make sense as that exception is not thrown by the parser. Please share the JSON and a complete minimal example.
ok. That information helped. From the error message it was not clear to me. I was able to find out what's going on and why it "just" stopped to work. The python json.dumps before was producing: "version": 1.1 But current python I used - 3.11 - created: "version": "1.1". And since I am calling data.value("version", 0.0), it crashed. The question is what's the solution, because I guess I am not going to be only one ....
It was my bug. The internal data format was changed from float to str. And it was obviously forgotten ... :( Sorry for the false alarm ...
Description
Reading a json file I am getting the error: terminate called after throwing an instance of 'nlohmann::json_abi_v3_11_3::detail::type_error' what(): [json.exception.type_error.302] type must be number, but is string Aborted (core dumped) But I tested my json with few tools like json_pp, or 'python -c "import sys,json;json.loads(sys.stdin.read());print('OK')"' and there was no problem. I am producing the json the same way all the time and there was no problem in other cases. I tried also the latest version of the lib but same same ....
Reproduction steps
using json = nlohmann::json;
std::ifstream f(fname);
json data = json::parse(f);
Expected vs. actual results
no crash vs. crash
Minimal code example
No response
Error messages
Compiler and operating system
g++ 11, Linux
Library version
3.11.2 and 3.11.3
Validation
develop
branch is used.