I am using the nlohmann parser to parse a json string, but my code is crashing.
My code
const std::string& dataStr; //I receive dataStr as a parameter, this is just to show type of dataStr
std::string jsonString(dataStr.c_str(), dataStr.c_str() + dataStr.length());
nlohmann::json jsonData = nlohmann::json::parse(jsonString);
I am getting dataStr as a parameter.
The call stack I am getting is
01 VCRUNTIME140!_CxxThrowException+0x66 [d:srcvctoolscrtvcruntimesrcehhrow.cpp @ 74]
02 !nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer>::parser::unexpect+0x116 [nlohmannjsoninclude
lohmannjson.hpp @ 11619]
03 !nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer>::parser::parse_internal+0x387 [nlohmannjsoninclude
lohmannjson.hpp @ 11584]
04 !nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer>::parser::parse+0x2b [nlohmannjsoninclude
lohmannjson.hpp @ 11387]
05 !nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer>::parse<std::_String_const_iterator<std::_String_val<std::_Simple_types<char> > >,0>+0x7d [
lohmannjsoninclude
lohmannjson.hpp @ 6436]
06 !nlohmann::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,bool,__int64,unsigned __int64,double,std::allocator,nlohmann::adl_serializer>::parse<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,0>+0x55 [nlohmannjsoninclude
lohmann*json.hpp* @ 6488]
Error
~ImportsOpen
lohmannjsoninclude
lohmannjson.hpp line 11619, parse error - unexpected.
The error is not reproducible for all jsons, that's why I want to know what does the error mean? Also can it be because the string I am parsing is too big(~20K chars). Any help appreciated, thanks in advance.