Hi, i have a hashmap that i want to serialize/deserialize to/from JSON.
here is my code snippet:
test.cpp: In function ‘int main()’:
test.cpp:26:53: error: no matching function for call to ‘nlohmann::basic_json<>::value(int, std::set<int>&)’
set<int> ValueSet = jdEmployees.value(3, nullSet);
^
In file included from test.cpp:2:0:
nlohmann/json.hpp:20279:15: note: candidate: template<class ValueType, typename std::enable_if<(nlohmann::detail::is_getable<nlohmann::basic_json<>, ValueType>::value && (! std::is_same<nlohmann::detail::value_t, ValueType>::value)), int>::type <anonymous> > ValueType nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::value(const typename nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::object_t::key_type&, const ValueType&) const [with ValueType = ValueType; typename std::enable_if<(nlohmann::detail::is_getable<nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>, ValueType>::value && (! std::is_same<nlohmann::detail::value_t, ValueType>::value)), int>::type <anonymous> = <enumerator>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; BinaryType = std::vector<unsigned char>]
ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const
^
nlohmann/json.hpp:20279:15: note: template argument deduction/substitution failed:
test.cpp:50:57: note: cannot convert ‘3’ (type ‘int’) to type ‘const key_type& {aka const std::__cxx11::basic_string<char>&}’
set<int> ValueSet = jdEmployees.value(3, nullSet);
^
In file included from test.cpp:2:0:
nlohmann/json.hpp:20301:14: note: candidate: nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::string_t nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::value(const typename nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::object_t::key_type&, const char*) const [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; BinaryType = std::vector<unsigned char>; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::string_t = std::__cxx11::basic_string<char>; typename nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::object_t::key_type = std::__cxx11::basic_string<char>]
string_t value(const typename object_t::key_type& key, const char* default_value) const
^
nlohmann/json.hpp:20301:14: note: no known conversion for argument 1 from ‘int’ to ‘const key_type& {aka const std::__cxx11::basic_string<char>&}’
nlohmann/json.hpp:20351:15: note: candidate: template<class ValueType, typename std::enable_if<nlohmann::detail::is_getable<nlohmann::basic_json<>, ValueType>::value, int>::type <anonymous> > ValueType nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::value(const json_pointer&, const ValueType&) const [with ValueType = ValueType; typename std::enable_if<nlohmann::detail::is_getable<nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>, ValueType>::value, int>::type <anonymous> = <enumerator>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; BinaryType = std::vector<unsigned char>]
ValueType value(const json_pointer& ptr, const ValueType& default_value) const
^
nlohmann/json.hpp:20351:15: note: template argument deduction/substitution failed:
test.cpp:50:57: note: cannot convert ‘3’ (type ‘int’) to type ‘const json_pointer& {aka const nlohmann::json_pointer<nlohmann::basic_json<> >&}’
set<int> ValueSet = jdEmployees.value(3, nullSet);
^
In file included from test.cpp:2:0:
nlohmann/json.hpp:20375:14: note: candidate: nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::string_t nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::value(const json_pointer&, const char*) const [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; BinaryType = std::vector<unsigned char>; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::string_t = std::__cxx11::basic_string<char>; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType>::json_pointer = nlohmann::json_pointer<nlohmann::basic_json<> >]
string_t value(const json_pointer& ptr, const char* default_value) const
^
nlohmann/json.hpp:20375:14: note: no known conversion for argument 1 from ‘int’ to ‘const json_pointer& {aka const nlohmann::json_pointer<nlohmann::basic_json<> >&}’
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.outHowever i get this error: