-
-
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
Error occurred when converting nlohmann::json to std::any #3428
Comments
Seems to work just fine for me with trunk: (GCC 11, Clang trunk, MSVC latest) Edit: Oh wait. That's a runtime issue. My bad. So, it's trying to assign the value as if |
Can I close this issue then? |
But I didn't get it…… why |
I cannot reproduce the runtime error. |
https://godbolt.org/z/T8fnsrKPz
Also, it only happens in the rvalue ref case and I haven't checked yet what type ends up being stored in the Edit: It is indeed a |
Thanks! So this only occurs on MSVC? Very strange. I would need to see the stack trace from the exception and the state of the |
I just tried again with Clang (trunk) and it works just fine with the rvalue ref. |
I think this can be fixed by Edit: I'm excluding it unconditionally, to suppress GCC compile failures with "-Werror=conversion". |
Fixes nlohmann#3428 (MSVC) and silences compiler warning on GCC (-Wconversion).
@falbrechtskirchinger @nlohmann Thanks for your hard work! |
Description
I would like to store objects in a
std::map<std::string, std::any>
. But convertingnlohmann::json
tostd::any
throws errortype must be string, but is
I can only reproduce this issue on Windows. macOS seems working fine.
Reproduction steps
Minimal test case:
Expected vs. actual results
Expected: Runs without error
Actual: Exception: Exception 0xe06d7363 encountered at address 0x7ffa855c466c
Minimal code example
No response
Error messages
The text was updated successfully, but these errors were encountered: