Closed elmajime closed 3 years ago
What version of Visual Studio are you using?
And which version of nlohmann::json?
Nlohmann version 3.7.1 and Visual studio 2019
And if you do a simple example only using nlohmann json and do std::string s = json_var.value()
, does this work in your environment?
Does the compiler tell why it is ambiguous?
I don't have the time to test right now but will do as soon as possible. But I also wanted to point out that I had to change the base CMakeLists.txt in order for Visual Studio to be able to compile the library nlohmann_json_schema_validator. The problem was that the project name and the target name where the same, this resulted in MSVC solution to contain all but the nlohmann_json_schema_validator target.
In the end I renamed the library target to lib_nlohmann_json_schema_validator so it's different from the project name and change the name of the output back to nlohmann_json_schema_validator like so:
<in the set_target_properties part> OUTPUT_NAME "nlohmann_json_schema_validator"
On the ambiguous error: it seems the compiler can't decide on which basic_string constructor to use. But that's what the Clang plugin tells me.
I've just tried this and got the same result:
nlohmann::json json_var = {
{"pi", 3.141},
{"happy", true},
{"name", "Niels"},
{"nothing", nullptr},
{"answer", {
{"everything", 42}
}},
{"list", {1, 0, 2}},
{"object", {
{"currency", "USD"},
{"value", 42.99}
}}
};
std::string s = json_var.value();
It's a problem of the compiler version. Could you try the latest version of nlohmann::json?
Ok, just tried with the latest version of Nlohmann Json : 3.9.1 and it works. I removed the hotfix I originaly made.
On another note: I had to change the CMakeLists.txt in order to have both Debug and Release versions of the library generated (with a suffix for the debug) in order to link correctly in static on Windows. I did that by adding DEBUG_POSTFIX d to the properties of the target. I thought you might want to know.
Thanks again for your help !
https://github.com/pboettch/json-schema-validator/blob/1519c845c2b1bbf35021feb11c23625de603ca1e/src/json-validator.cpp#L730
Might be changed to:
patternString_ = attr.value().get<std::string>();
to avoid compilation error:
Error C2593: 'operator =' is ambiguous nlohmann_json_schema_validator
The problem is present on version tagged 2.1.0 as well but on line 666.