I have this c++ example code:
void test()
{
rapidjson::Document doc;
doc.SetObject();
const std::string source = "The quick brown fox jumps over the lazy dog";
rapidjson::Value source_val;
source_val.SetString( source.c_str(), source.length(), doc.GetAllocator() );
}
And at compile time, on x64 platform, I get this warning:
warning C4267: 'argument': conversion from
size_t
torapidjson::SizeType
, possible loss of data
How can I correctly convert from a string's length (size_t
) to rapidjson SizeType?
RapidJSON uses 32-bit array/string indices even on 64-bit platforms, instead of using
size_t
. Users may override the SizeType by defining RAPIDJSON_NO_SIZETYPEDEFINE.