Closed av4625 closed 1 year ago
The issue is in line
const nlohmann::json track_id{nlohmann::json::parse(f)};
which is interpreted differently by different compilers, see #2311.
Change it to
const nlohmann::json track_id = nlohmann::json::parse(f);
and it should work.
Description
When I parse json and use the operator[] with a string value it throws an exception saying it can't be used with an array even though there is no array in the json.
Reproduction steps
Get a value from json using operator[]. I think the code below explains the steps.
I am able to run the exact same code when compiled with apple clang 14.0.0 with no issue.
But when I run it when it was compiled with gcc/g++ 11.3 (for arm) I get the exception.
I use conan to get the library and set arch to
armv7hf
Expected vs. actual results
I expect no exception to be thrown, but I get the following:
Minimal code example
I store the json to a file like this:
I then get and parse the json like this:
The json file correctly contains:
Interestingly 🤨 the
std::cout
prints:Edit: I found that changing:
to:
or:
fixes the issue. This should be the same thing in later cpp versions right? I compile both for c++17 when using apple clang and gcc 11.3 (for arm).
Error messages
No response
Compiler and operating system
Linux gcc/g++ 11.3
arm-linux-gnueabihf-gcc-11
/arm-linux-gnueabihf-g++-11
Library version
3.11.2
Validation
develop
branch is used.