You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I may be doing something stupid, but I'm trying to use std::wstring as my string type. If I call json::dump on my wstring'ed json object, it seems to not be able to convert from char to wchar_t if I correctly understand an error message that is too verbose to not be opaque. I quote the errors at the bottom. This is with VisualStudio 2017. I cloned the git repo a few weeks ago, and haven't tried with the latest version, but I didn't see any pertinent checkins in the meantime. I may have missed them of course. Likewise for examples that use a different string type, I also didn't find any closed issues referring to wchar_t or std::wstring.
My declarations look like:
namespace utility { typedef string_t std::wstring; }
nlohmann::basic_json<std::map, std::vector, utility::string_t> j = njson::parse(wbody); // here wbody is of type std::wstring
and the call to dump is utility::string_t dump = j.dump(0); // again utility::string_t is std::wstring.
Is this expected?
Thank you for your good work. The library has really made my life a lot easier.
(The first warning always appears when including the header, and is unrelated.)
1>C:\tobi\Source\json/json.hpp(5961): warning C4819: The file contains a character that cannot be represented in the current code page (932). Save the file in Unicode format to prevent data loss
1>C:\tobi\Source\json/json.hpp(8999): error C2440: '<function-style-cast>': cannot convert from 'std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>' to 'nlohmann::detail::output_adapter<char>'
1>C:\tobi\Source\json/json.hpp(8999): note: No constructor could take the source type, or constructor overload resolution was ambiguous
1>C:\tobi\Source\json/json.hpp(8997): note: while compiling class template member function 'std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>> nlohmann::basic_json<std::map,std::vector,utility::string_t,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>::dump(const int,const char,const bool) const'
1>C:\tobi\Source\source.cpp(57): note: see reference to function template instantiation 'std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>> nlohmann::basic_json<std::map,std::vector,utility::string_t,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>::dump(const int,const char,const bool) const' being compiled
1>C:\tobi\Source\source.cpp(34): note: see reference to class template instantiation 'nlohmann::basic_json<std::map,std::vector,utility::string_t,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>' being compiled
1>C:\tobi\Source\json/json.hpp(8999): error C2664: 'nlohmann::detail::serializer<nlohmann::basic_json<std::map,std::vector,utility::string_t,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>::serializer(const nlohmann::detail::serializer<nlohmann::basic_json<std::map,std::vector,utility::string_t,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>> &)': cannot convert argument 1 from 'const char' to 'const nlohmann::detail::serializer<nlohmann::basic_json<std::map,std::vector,utility::string_t,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>> &'
1>C:\tobi\Source\json/json.hpp(8999): note: Reason: cannot convert from 'const char' to 'const nlohmann::detail::serializer<nlohmann::basic_json<std::map,std::vector,utility::string_t,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>>'
1>C:\tobi\Source\json/json.hpp(8999): note: No constructor could take the source type, or constructor overload resolution was ambiguous
The text was updated successfully, but these errors were encountered:
Currently, std::wstring is not supported by the library. Even though the string type is templated, there are too many assumptions in the code that rely on using std::string. Sorry about that :-/
I figured that the lack of documentation on how to use arbitrary string types was no accident, so I didn't bet all my chips on this. I would have been mightily impressed if it worked though!
I don't know your policy, so I'm not going to close this issue myself, but please feel free to do so, no feelings hurt :)
I may be doing something stupid, but I'm trying to use std::wstring as my string type. If I call json::dump on my wstring'ed json object, it seems to not be able to convert from char to wchar_t if I correctly understand an error message that is too verbose to not be opaque. I quote the errors at the bottom. This is with VisualStudio 2017. I cloned the git repo a few weeks ago, and haven't tried with the latest version, but I didn't see any pertinent checkins in the meantime. I may have missed them of course. Likewise for examples that use a different string type, I also didn't find any closed issues referring to wchar_t or std::wstring.
My declarations look like:
and the call to dump is
utility::string_t dump = j.dump(0); // again utility::string_t is std::wstring.
Is this expected?
Thank you for your good work. The library has really made my life a lot easier.
(The first warning always appears when including the header, and is unrelated.)
The text was updated successfully, but these errors were encountered: