Hey there. Android studio project for android.
ndk = r13b
min sdk version = 15
target sdk version = 19
rapidjson::Document d;
std::string file = "res/data.json";
// TODO: try
// TODO: std::string file = "data.json";
// TODO: try
// TODO: std::string content = FileUtils::getInstance()->getStringFromFile(FileUtils::getInstance()->fullPathForFilename(file.c_str()));
std::string content = FileUtils::getInstance()->getStringFromFile(file.c_str());
log("file content: %s", content.c_str());
d.Parse<0>(content.c_str());
if (d.HasParseError()) {
log("\nerror test(offset %u): %d\n", (unsigned)d.GetErrorOffset(), d.GetParseError());
log("error");
} else
{
log("no error");
}
log("parsed json: %s", d.GetString());
And the data.json is : {"level":{"three":["ABE","ABY","ACE","ACT","ADD","ADO","AFT","AGA"],"four":["hdgs","asdjkas"]}}
and it’s a valid json.(validation confirmed)
Well the file content is loaded, logged but without any parse error (d.HasParseError returns false meaning there is no error) d.Parse<0>(content.c_str());
fails with message json/document.h:1681: const Ch* rapidjson::GenericValue<Encoding, Allocator>::GetString() const [with Encoding = rapidjson::UTF8<>; Allocator = rapidjson::MemoryPoolAllocator<>; rapidjson::GenericValue<Encoding, Allocator>::Ch = char]: assertion "IsString()" failed
Any help is appreciated. (apk tested on both simulator and real device and both fail)