本文整理汇总了C++中JSONNode::GetNode方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONNode::GetNode方法的具体用法?C++ JSONNode::GetNode怎么用?C++ JSONNode::GetNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONNode
的用法示例。
在下文中一共展示了JSONNode::GetNode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse
void LocalHighscores::parse() {
ARK2D::getLog()->v("Parsing LocalHighscores");
string s;
#if defined(ARK2D_ANDROID)
if (m_threaded && m_data != NULL) {
s = string((char*) m_data);
} else if (StringUtil::file_exists(m_filename.c_str())) {
s = StringUtil::file_get_contents(m_filename.c_str());
} else {
s = string((char*) m_data);
}
#else
if (m_data != NULL) {
s = string((char*) m_data);
} else {
s = StringUtil::file_get_contents(m_filename.c_str());
}
#endif
ARK2D::getLog()->v(StringUtil::append("JSON String is: ", s));
if (s.length() == 0) {
ARK2D::getLog()->e("JSON String was empty. Huh?");
return;
}
if (s == "[]") {
ARK2D::getLog()->v("Local highscores were blank. That's fine. ");
} else {
JSONNode* arr = libJSON::Parse(s);
if (arr == NULL) {
ARK2D::getLog()->e("Could not parse json");
return;
}
for(unsigned int i = 0; i < arr->NodeSize(); i++) {
JSONNode* item = arr->NodeAt(i);
LocalHighscoreItem* it = new LocalHighscoreItem();
it->name = item->GetNode("name")->NodeAsString();
it->score = item->GetNode("score")->NodeAsInt();
//StringUtil::str_replace("\"", "\\\"", it->name);
m_items.push_back(it);
}
ARK2D::getLog()->i("loaded local highscores");
// fix memory leaks
ARK2D::getLog()->i("Freeing up memory.");
libJSON::Delete(arr);
}
this->sort();
}
示例2: createFromJSON
PathGroup* PathIO::createFromJSON(string json) {
#ifdef EXCEPTIONS_AVAILABLE
try {
#endif
JSONNode* root = libJSON::Parse(json);
PathGroup* pathGroup = new PathGroup();
pathGroup->setName(root->GetNode("name")->NodeAsString());
pathGroup->setDescription(root->GetNode("description")->NodeAsString());
if (root->GetNode("relative") == NULL) {
pathGroup->setRelative(false);
} else {
pathGroup->setRelative(root->GetNode("relative")->NodeAsBool());
}
JSONNode* paths = root->GetNode("paths");
for(unsigned int i = 0; i < paths->NodeSize(); i++)
{
JSONNode* path = paths->Children[i];
Path* pathObj = new Path();
pathObj->setDuration(path->GetNode("duration")->NodeAsFloat());
pathObj->setEasing(Easing::getByString(path->GetNode("easing")->NodeAsString()));
JSONNode* points = path->GetNode("points");
for(unsigned int j = 0; j < points->NodeSize(); j++)
{
JSONNode* point = points->Children[j];
pathObj->addPoint(point->GetNode("x")->NodeAsInt(), point->GetNode("y")->NodeAsInt());
}
pathGroup->addPath(pathObj);
}
return pathGroup;
#ifdef EXCEPTIONS_AVAILABLE
} catch(...) {
ErrorDialog::createAndShow("exception in PathIO::createFromJson");
return NULL;
}
#endif
return NULL;
}
示例3: sd
void CBrowserDlg::NavigateComplete2Explorer1(LPDISPATCH pDisp, VARIANT* URL)
{
// “ут мы ловим редиректы.
KillTimer(100);
CString u=ie.get_LocationURL();
if(logout){
if(u.Find(L"http://vkontakte.ru/login.php")==0){ // «начит в IE уже вышли, закрываем окно
CDialog::OnOK();
}
if(logoutClicked){
CDialog::OnOK();
}
}
if(u.Find(L"http://vkontakte.ru/api/login_success.html")==0){
wchar_t* _url=URL->bstrVal;
wcstok(_url, L"=");
wchar_t* session_data=wcstok(NULL, L"=");
std::wstring sd(CUtils::urlDecode(session_data));
JSONNode* json = libJSON::Parse(sd);
wchar_t* wsid=(wchar_t*)json->GetNode(L"sid")->NodeAsString().c_str();
wchar_t* wsecret=(wchar_t*)json->GetNode(L"secret")->NodeAsString().c_str();
wchar_t* uid_s=(wchar_t*)json->GetNode(L"mid")->NodeAsString().c_str();
char* uid_c=CUtils::wtoc(uid_s, wcslen(uid_s));
uid=atoi(uid_c);
sid=CUtils::wtoc(wsid, wcslen(wsid)+1);
secret=CUtils::wtoc(wsecret, wcslen(wsecret)+1);
delete [] wsid, wsecret, uid_s, uid_c;
CDialog::OnOK();
}
if(u.Find(L"http://vkontakte.ru/api/login_failure.html")==0){
MessageBox(L"јвторизаци¤ не удалась.", NULL, MB_OK | MB_ICONEXCLAMATION);
CDialog::OnCancel();
}
}