I have this code:
JSONObject object;
if (value->IsObject())
{
object = value->AsObject();
const wchar_t *tmp = from_string(entity_id);
std::wcout << tmp << std::endl;
std::wcout.flush();
if (object.find(tmp) != object.end())
{
std::wcout << tmp << std::endl;
std::wcout.flush();
initFromJSON(object[tmp]->AsObject());
}
else
{
return false;
}
}
Problem here is that after inner if statement, the content of a tmp is empty. Before that it's not. When I try debuggin, it's everything ok, the content is not deleted. But when I run program, content is deleted. Any idea why?
Method from_string(entity_id) only convert from string to wchar like this:
std::wstring result;
for (int i = 0; i<content.length(); i++)
result += wchar_t(content[i]);
return result.c_str();
Methods JSONObject::find(...) and JSONObject::end() are this:
iterator find(const key_type& __k) {return __tree_.find(__k);}
iterator end() _NOEXCEPT {return __tree_.end();}
I don't believe that is problem in find(...) or in end(). I'm guessing that problem is somewhere else but I cannot locate it. Because the content of wchar is empty after the if statement I cannot say
initFromJSON(object[tmp]->AsObject());
because object[tmp] doesn't exist.
Any advice what am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire