本文整理汇总了C++中JsonArray::GetCount方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonArray::GetCount方法的具体用法?C++ JsonArray::GetCount怎么用?C++ JsonArray::GetCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonArray
的用法示例。
在下文中一共展示了JsonArray::GetCount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessChatUsers
result VKUMessagesListItemProvider::ProcessChatUsers(const JsonObject * chatJson) {
AppLog("VKUMessagesListItemProvider::ProcessChatUsers");
result r = E_SUCCESS;
JsonArray *chatUsers;
JsonParseUtils::GetArray(chatJson, L"users", chatUsers);
_pUserIdAvatarMap = new HashMap(SingleObjectDeleter);
_pUserIdAvatarMap->Construct(chatUsers->GetCount(), 1);
for (int i=0; i<chatUsers->GetCount(); i++) {
JsonObject *userJson;
JsonParseUtils::GetObject(chatUsers, i, userJson);
int userId;
String avatarUrl;
JsonParseUtils::GetInteger(*userJson, L"id", userId);
JsonParseUtils::GetString(*userJson, L"photo_100", avatarUrl);
AppLog("Adding avatar for %d : %ls", userId, avatarUrl.GetPointer());
_pUserIdAvatarMap->Add(new Integer(userId), new String(avatarUrl));
}
return r;
}
示例2: OnResponseN
void VKUMessagesListItemProvider::OnResponseN(RequestId requestId, JsonObject *object) {
result r = E_SUCCESS;
String cacheFile(VKUApp::GetInstance()->GetCacheDir() + "dialog" + Integer::ToString(_peerId) + ".json");
JsonObject *response;
JsonArray *items;
AppLog("processing messages json");
r = JsonParseUtils::GetObject(object, L"response", response);
TryCatch(r == E_SUCCESS, , "failed get response from object");
r = JsonParseUtils::GetArray(response, L"items", items);
TryCatch(r == E_SUCCESS, , "failed get items from response");
if(requestId == REQUEST_GET_NEW_MESSAGE) {
if(_messagesJson == null) {
AppLog("Assigned %d items", items->GetCount());
_messagesJson = items->CloneN();
} else {
AppLog("added %d items", items->GetCount());
for(int i = 0; i < items->GetCount(); i++) {
IJsonValue *value;
items->GetAt(i, value);
_messagesJson->InsertAt(static_cast<JsonObject *>(value)->CloneN(), 0);
}
}
_tableView->UpdateTableView();
TryCatch(GetLastResult() == E_SUCCESS, r = GetLastResult() , "Failed pTableView->UpdateTableView");
_tableView->RequestRedraw(true);
TryCatch(GetLastResult() == E_SUCCESS, r = GetLastResult() , "Failed pTableView->RequestRedraw");
r = _tableView->ScrollToItem(_tableView->GetItemCount() - 1);
TryCatch(r == E_SUCCESS, , "Failed pTableView->ScrollToItem");
JsonWriter::Compose(_messagesJson, cacheFile);
} else if(requestId == REQUEST_UPDATE_HISTORY) {
示例3: OnTransactionReadyToRead
void GHPlayerController::OnTransactionReadyToRead(Tizen::Base::String apiCode, Tizen::Base::String statusCode, Tizen::Web::Json::IJsonValue* data)
{
AppLogDebug("[DEBUG] apiCode : %S", apiCode.GetPointer() );
AppLogDebug("[DEBUG] statusCode : %S", statusCode.GetPointer());
if(pProgressPopup->IsVisible()) {
pProgressPopup->SetShowState(false);
}
if(apiCode.Equals(PLAYER_LOGIN)) {
// 정상적으로 결과를 반환했을 때
if(statusCode != "0") {
// Save AppRegistry Data(Email, Password)----------
appReg.put(appReg.email, playerEmail);
appReg.put(appReg.pwd, playerPwd);
//------------------------------------------------
GHSharedAuthData & sharedInstance = GHSharedAuthData::getSharedInstance();
sharedInstance.setPlayerId(statusCode);
if(this->currentListener != null) this->currentListener->loginPlayerFinished(statusCode);
}
else { // 에러가 발생했을 때
}
}
else if(apiCode.Equals(PLAYER_PLAYERDATA)) { // PLAYER_PLAYERDATA
GHPlayer *player;
// 정상적으로 결과를 반환했을 때
if(statusCode == "1") {
JsonObject *pJsonOject = static_cast<JsonObject*>(data);
AppLogDebug("---------------------------2-----------------------");
String* pkeyId = new String(L"player_id");
String* pkeyEmail = new String(L"email");
String* pkeyName = new String(L"name");
String* pkeyImgUrl = new String(L"img_url");
String* pkeyIsFriend= new String(L"is_friend");
String sId = getStringByKey(pJsonOject, pkeyId);
String sEmail = getStringByKey(pJsonOject, pkeyEmail);
String sName = getStringByKey(pJsonOject, pkeyName);
String sImgUrl = getStringByKey(pJsonOject, pkeyImgUrl);
bool bIsFriend = getBoolByKey(pJsonOject, pkeyIsFriend);
AppLogDebug("--------------------------------------------------");
player = new GHPlayer(sId, sEmail, sName, sImgUrl);
player->setIsFriend(bIsFriend);
// KEY NAME DELETE
delete pkeyId; delete pkeyEmail;
delete pkeyName; delete pkeyImgUrl;
delete pkeyIsFriend;
}
else { // 에러가 발생했을 때
player = null;
}
if(this->currentListener != null) this->currentListener->loadPlayerDataFinished(player);
}
else if(apiCode.Equals(PLAYER_GAMELIST))
{
ArrayList *gameList;
// 정상적으로 결과를 반환했을 때
if(statusCode == "1") {
JsonArray* pJsonArray = static_cast<JsonArray*>(data);
int arrNum = pJsonArray->GetCount();
gameList = new ArrayList();
// KEY NAME
String* pKeyGameId = new String(L"game_id");
String* pKeyGameTitle = new String(L"title");
String* pkeyGameImgUrl = new String(L"img_url");
String* pKeyGameDesc = new String(L"description");
AppLogDebug("[DEBUG] arrNum : %d", arrNum );
for(int i=0; i<arrNum; i++) {
JsonObject *pJsonOject = getJsonObjectByIndex(pJsonArray, i);
// 데이터 파싱
String sGameId = getStringByKey(pJsonOject, pKeyGameId);
String sGameTitle = getStringByKey(pJsonOject, pKeyGameTitle);
String sGameImgUrl = getStringByKey(pJsonOject, pkeyGameImgUrl);
String sGameDesc = getStringByKey(pJsonOject, pKeyGameDesc);
// 리스트에 추가
gameList->Add( new GHGame(sGameId, "", sGameTitle, sGameDesc, sGameImgUrl, 0, 0, 0, false, false) );
}
// KEY NAME DELETE
delete pKeyGameId; delete pKeyGameTitle; delete pkeyGameImgUrl;
}
//.........这里部分代码省略.........
示例4: User
//Recursively traverse IJsonValue obtained by parser (using ParseN)
void
ProjectGiraffeTab1::TraverseFunction(IJsonValue* pValue)
{
TryReturnVoid(_tableView, "tableView is null");
TryReturnVoid(pValue, "input jsonvalue pointer is null");
User *dummyUser = new User();
dummyUser->setUsername(L"CS210 Student");
Graffiti *lastCreatedGraffiti = NULL;
switch (pValue->GetType())
{
case JSON_TYPE_OBJECT:
{
JsonObject* pObject = static_cast< JsonObject* >(pValue);
IMapEnumeratorT< const String*, IJsonValue* >* pMapEnum = pObject->GetMapEnumeratorN();
while (pMapEnum->MoveNext() == E_SUCCESS)
{
AppLog("IN JSON OBJECT");
const String* key = null;
IJsonValue* value = null;
pMapEnum->GetKey(key);
pMapEnum->GetValue(value);
String* pListKey = new (std::nothrow) String(*key);
_pJsonKeyList->Add(*pListKey);
AppLog("Key: %ls", pListKey->GetPointer());
if(pListKey->Equals("message",true)){
AppLog("Message received");
lastCreatedGraffiti = new Graffiti();
lastCreatedGraffiti->setUser(dummyUser);
JsonString* pVal = static_cast< JsonString* >(value);
String* pListValue = new (std::nothrow) String(*pVal);
lastCreatedGraffiti->setText(String(*pListValue));
_items->Add(lastCreatedGraffiti);
AppLog("message : %ls", lastCreatedGraffiti->text().GetPointer());
} else if (value && pListKey->Equals("latitude", true)) {
JsonNumber *jsonNum = static_cast<JsonNumber *>(value);
Double *latValue = static_cast<Double *>(jsonNum);
if (latValue && lastCreatedGraffiti) {
lastCreatedGraffiti->setLatitude(latValue->ToFloat());
AppLog("latitude : %f", lastCreatedGraffiti->longitude());
}
} else if (value != NULL && pListKey->Equals("longitude", true)) {
JsonNumber *jsonNum = static_cast<JsonNumber *>(value);
Double *lonValue = static_cast<Double *>(jsonNum);
if (lonValue && lastCreatedGraffiti) {
lastCreatedGraffiti->setLongitude(lonValue->ToFloat());
AppLog("longitude : %f", lastCreatedGraffiti->longitude());
}
}
}
delete pMapEnum;
}
break;
case JSON_TYPE_STRING:
{
JsonString* pVal = static_cast< JsonString* >(pValue);
if (_isArray == 0)
{
String* pStr = new (std::nothrow) String(*pVal);
_pValueList->Add(*pStr);
}
}
break;
case JSON_TYPE_ARRAY:
{
JsonArray* pJsonArray = static_cast< JsonArray* >(pValue);
pJsonArray->GetCount();
IEnumeratorT< IJsonValue* >* pEnum = pJsonArray->GetEnumeratorN();
while (pEnum->MoveNext() == E_SUCCESS)
{
IJsonValue* pValue = null;
pEnum->GetCurrent(pValue);
if ((pValue->GetType() == JSON_TYPE_STRING) ||
(pValue->GetType() == JSON_TYPE_NUMBER) ||
(pValue->GetType() == JSON_TYPE_BOOL) ||
(pValue->GetType() == JSON_TYPE_NULL)) {
_isArray = 1;
}
TraverseFunction(pValue);
}
delete pEnum;
}
break;
case JSON_TYPE_NUMBER:
{
JsonNumber* pVal = static_cast< JsonNumber* >(pValue);
String* pStr = new (std::nothrow) String((pVal->ToString()));
if (_isArray == 0)
_pValueList->Add(*pStr);
}
break;
//.........这里部分代码省略.........
示例5: ArrayList
ArrayList * VKUMessagesListItemProvider::GetMessageElementsN(const JsonObject *pMessageJson, int itemWidth) {
AppLog("enter VKUMessagesListItemProvider::GetMessageElementsN");
result r;
// general
ArrayList* pResultArray;
// body stuff
String messageText;
MessageTextElement *pMessageTextElement;
// attachs stuff
IJsonValue *attachs;
JsonArray * pAttachArray;
int out;
int emoji = 0;
pResultArray = new ArrayList(SingleObjectDeleter);
r = pResultArray->Construct(1);
TryCatch(r == E_SUCCESS, , "pResultArray->Construct");
JsonParseUtils::GetInteger(*pMessageJson, L"out", out);
JsonObject * geoObject;
r = JsonParseUtils::GetObject(pMessageJson, L"geo", geoObject);
if (r == E_SUCCESS) {
AppLog("Message has geo entry, receiving");
MessageLocationElement * pLocationElement = new MessageLocationElement();
pLocationElement->Construct(Rectangle(0, 0, 400, 400), geoObject);
pResultArray->Add(pLocationElement);
}
r = JsonParseUtils::GetString(*pMessageJson, L"body", messageText);
TryCatch(r == E_SUCCESS, , "JsonParseUtils::GetString body");
JsonParseUtils::GetInteger(*pMessageJson, L"emoji", emoji);
if (messageText.GetLength() != 0) {
AppLog("Message has text entry, receiving");
pMessageTextElement = new MessageTextElement();
pMessageTextElement->Construct(Rectangle(0, 0, itemWidth-200, 10000));
pMessageTextElement->SetText(messageText, emoji);
pResultArray->Add(pMessageTextElement);
}
static const String attachConst(L"attachments");
r = pMessageJson->GetValue(&attachConst, attachs);
if (r == E_SUCCESS)
pAttachArray = static_cast<JsonArray *>(attachs);
for (int i=0; r == E_SUCCESS && i<pAttachArray->GetCount(); i++) {
AppLog("Message has %d attachments, receiving %d", pAttachArray->GetCount(), i);
IJsonValue *pAttachValue;
JsonObject *pAttachObject;
String attachType;
MessageElement *pMessageElement;
pAttachArray->GetAt(i, pAttachValue);
pAttachObject = static_cast<JsonObject *>(pAttachValue);
JsonParseUtils::GetString(*pAttachObject, L"type", attachType);
if (attachType == L"photo") {
AppLog("Message has photo, receiving");
String imageUrl;
IJsonValue *pPhotoValue;
JsonObject *pPhotoObject;
Rectangle thumbSize;
int width = 0, height = 0;
static const String photoConst(L"photo");
pAttachObject->GetValue(&photoConst, pPhotoValue);
pPhotoObject = static_cast<JsonObject *>(pPhotoValue);
JsonParseUtils::GetString(*pPhotoObject, L"photo_604", imageUrl);
JsonParseUtils::GetInteger(*pPhotoObject, L"width", width);
JsonParseUtils::GetInteger(*pPhotoObject, L"height", height);
if (width != 0 && height != 0) {
thumbSize = ImageUtils::ScaleTo(320, Rectangle(0, 0, width, height));
} else {
thumbSize = Rectangle(0, 0, 320, 240);
}
MessagePhotoElement * pPhotoElement = new MessagePhotoElement();
pPhotoElement->Construct(thumbSize, imageUrl);
pMessageElement = static_cast<MessageElement *>(pPhotoElement);;
//.........这里部分代码省略.........