-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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: no matching function for call to ‘nlohmann::basic_json<>::value(int, std::set<int>&)’ #2671
Comments
leonardltk, I have just read the docs for json, there is no member function
|
Please have a look at the documentation and examples of the |
set<int> ValueSet = jdEmployees.value(3, " a default value that you want return, if key not found" ); a default value has to be an integer? so it means i cannot define |
Example: #include <iostream>
#include <set>
#include "json.hpp"
using json = nlohmann::json;
int main()
{
json j;
// create a JSON object and store an array with 4 integers at key "key"
j["key"] = {1,2,3,4};
// access call via []
std::set<int> s1 = j["key"];
// access via value
std::set<int> nullset;
std::set<int> s2 = j.value("key", json(nullset));
std::set<int> s3 = j.value("nonexisting", json(nullset));
} |
Do you need further assistance with this issue? |
I am doing a simple assignment data["Name"] = { 'W', 'O', '1' }; in Visual Studio 2022. It won't compile, I get the error code C2678, because of the error: "No operator "=" matches these operands. I used this line: using json = nlohmann::json;. To include the namespace. The declaration statement for data is: nlohmann::json data; I also tried another line of code that has worked for other coders: data["key"] = { 1, 2, 3 }; This too generates the same error. Why am I seeing this error? |
@blandrum2 That's because there is no assignment operator on |
Hi, i have a hashmap that i want to serialize/deserialize to/from JSON.
here is my code snippet:
I compiled it like this:
g++ -o ./debug.out -std=c++11 test.cpp nlohmann/json.hpp && ./debug.out
However i get this error:
The text was updated successfully, but these errors were encountered: