本文整理汇总了C++中JSONArray::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONArray::begin方法的具体用法?C++ JSONArray::begin怎么用?C++ JSONArray::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONArray
的用法示例。
在下文中一共展示了JSONArray::begin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseJsonStr
void CTestJSON::parseJsonStr( const std::wstring& strJsonStr )
{
JSONValue* jsInput = JSON::Parse(strJsonStr.c_str());
if (jsInput == NULL || !jsInput->IsObject())
{
return;
}
JSONObject::const_iterator itResult = jsInput->AsObject().find(L"result");
if (itResult != jsInput->AsObject().end())
{
std::wstring strResult = itResult->second->AsString();
std::wcout << L"result" << L":" << strResult << std::endl;
}
JSONObject::const_iterator itLove = jsInput->AsObject().find(L"Love");
if (itLove != jsInput->AsObject().end())
{
std::wstring strResult = itLove->second->AsString();
std::wcout << L"Love" << L":" << strResult << std::endl;
}
JSONArray jsArray;
JSONObject::const_iterator itContents = jsInput->AsObject().find(L"contents");
if (itContents != jsInput->AsObject().end() && itContents->second != NULL && itContents->second->IsArray())
{
jsArray = itContents->second->AsArray();
}
std::wcout << "[" << std::endl;
JSONArray::iterator it = jsArray.begin();
JSONArray::iterator itEnd = jsArray.end();
for (; it != itEnd; ++it)
{
JSONValue* jsValue = *it;
if (jsValue->IsObject())
{
jsValue->AsObject();
JSONObject::const_iterator itObj = jsValue->AsObject().begin();
JSONObject::const_iterator itObjEnd = jsValue->AsObject().end();
for (; itObj != itObjEnd; ++itObj)
{
std::wstring strValue = itObj->second->AsString();
std::wcout << L"{" << itObj->first << L":" << strValue << L"}" << std::endl;
}
}
else if (jsValue->IsString())
{
std::wstring strValue = jsValue->AsString();
std::wcout << strValue << std::endl;
}
else if (jsValue->IsNumber())
{
double dValue = jsValue->AsNumber();
std::wcout << dValue << std::endl;
}
//...
}
std::wcout << "]" << std::endl;
}
示例2: bday_thread
unsigned WINAPI bday_thread(LPVOID)
{
SYSTEMTIME st;
GetSystemTime(&st);
wostringstream q;
q << L"SELECT+name%2c+profile_url+from+user+where+uid+in+(select+uid2+from+friend+where+uid1+%3d+me())+and+strpos(birthday_date%2c%22";
q << (st.wMonth);
q << L"%2f";
q << (st.wDay);
q << L"%22)%3e%3d0";
wstring fql = q.str();
JSONValue *j = fql_query(fql.c_str());
if(j)
{
JSONObject obj = j->AsObject();
JSONArray data = (obj[L"data"] ? obj[L"data"]->AsArray(): JSONArray());
for(JSONArray::const_iterator i = data.begin();i != data.end(); ++i)
{
JSONObject i_obj = (*i)->AsObject();
wstring name = i_obj[L"name"]->AsString();
name += L" ma urodziny!";
wstring url = i_obj[L"profile_url"]->AsString();
display_notif(wstring(L"Facebook Urodziny"), name, url);
}
delete j;
}
return 0;
}
示例3: if
CJSONElement::~CJSONElement()
{
if (m_type == TYPESTRING)
{
delete (string*)m_data.m_ptr;
}
else if (m_type == TYPEMAP)
{
JSONMap* map = (JSONMap*)m_data.m_ptr;
for (JSONMap::iterator it = map->begin(); it != map->end(); it++)
delete it->second;
delete (JSONMap*)m_data.m_ptr;
}
else if (m_type == TYPEARRAY)
{
JSONArray* array = (JSONArray*)m_data.m_ptr;
for (JSONArray::iterator it = array->begin(); it != array->end(); it++)
delete *it;
delete (JSONArray*)m_data.m_ptr;
}
delete m_error;
}
示例4: notif_thread
unsigned WINAPI notif_thread(LPVOID)
{
JSONValue *j = fql_query(L"select+title_text%2c+href%2c+icon_url+from+notification+where+recipient_id+%3d+me()+and+is_unread");
if(j && j->IsObject())
{
JSONObject obj = j->AsObject();
JSONArray data = obj[L"data"]->AsArray();
for(JSONArray::const_iterator i = data.begin();i != data.end();++i)
{
if(!((*i)->IsObject()))
continue;
JSONObject i_obj = (*i)->AsObject();
wstring href, title_text;
href = i_obj[L"href"]->AsString();
title_text = i_obj[L"title_text"]->AsString();
display_notif(wstring(L"Facebook Notification"), title_text, href);
}
delete j;
}
return 0;
}