-
-
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
Compilation error with std::map<std::string, std::string> on vs 2015 #734
Comments
I can run your above example without problems with Xcode #include "json.hpp"
using json = nlohmann::json;
int main(int argc, char const *argv[])
{
json j = {{"key", "value"}};
std::map<std::string, std::string> m;
m = j.get<decltype(m)>();
} I can confirm the error with |
oh, sorry forget to tell that I faced the problem on vs2015. |
Just to make sure: Can you compile and run the test suite without problems? |
no, I'm using the code #include "json.hpp"
using json = nlohmann::json;
int main(int argc, char const *argv[])
{
json j;
std::map<std::string, std::string> m;
m = j.get<decltype(m)>();
} I think there is no difference between your code and mine. :) |
Do you run at least Microsoft Visual C++ 2015 / Build Tools 14.0.25123.0? |
vs2015 with update 3, I need tomorrow to check the version number. |
And I have switched to vs 2017, still has problem. |
I found if I change std::map<std::string, std::string> to std::map<std::string, int>, then it works without problems. |
Sorry for not checking back earlier. Can I close this issue or is there still anything wrong with the library? |
I still cannot convert this type into json using vs2015, so I write the special convert code for this type. It's fine to close it and I wish anyone had same problem could give me some advise. |
I just tried this out on both VS 2015 and VS 2017. It compiles with no issues. Should be safe to close. @leozzyzheng perhaps try again with latest code? |
@jseward I will try it later, thanks. |
@jseward I have downloaded the latest release version on github and used the exactly same code from nlohmann, unfortunately it still have the same compilation error. |
Sorry for the late reply, I'm looking into it. |
I have no problem with VS2015 14.0.25431.01 Update 3 and the latest |
I am confused... |
@theodelrieu The latest |
Thanks for checking everyone! |
TL:DR; I duplicated this with #827. Now I'm gonna do the reading. I have json.h 2.11 from the releases page, and VS 2015 Update 14.0.25431.01 Update 3, on x64 Windows 10, and I'm still suffering this.. do I need a patched or more recent version? My issue is exactly the same as the one reported by @leozzyzheng:
My project is a Unicode project. Wouldn't have thought that'd make a difference, though (I'm handling std::string for JSON data)? I have investigated leozzyzhengs solution, I think it looks like this for me. Leaving it here for anyone who needs it.
|
using json = nlohmann::json; json j; std::map<std::string, std::string> m; m = j.get<decltype(m)>();
it says
error C2665: 'std::pair<const _Kty,_Ty>::pair': none of the 2 overloads could convert all the argument types
if I change to
it says
'operator =' is ambiguous
Did I miss anything about converting map data to/from json ?
The text was updated successfully, but these errors were encountered: