本文整理汇总了C++中JsonArray::GetAt方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonArray::GetAt方法的具体用法?C++ JsonArray::GetAt怎么用?C++ JsonArray::GetAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonArray
的用法示例。
在下文中一共展示了JsonArray::GetAt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnResponseN
void VKSettingsPanel::OnResponseN(RequestId requestId, Tizen::Web::Json::JsonObject *object) {
if (requestId == REQUEST_GET_MYSELF) {
JsonArray* resp;
JsonParseUtils::GetArray(object, L"response", resp);
WebImageView *pWebImage;
JsonObject* item;
IJsonValue *itemValue;
resp->GetAt(0, itemValue);
item = static_cast<JsonObject *>(itemValue);
String firstName, lastName, photoMax;
JsonParseUtils::GetString(*item, L"first_name", firstName);
JsonParseUtils::GetString(*item, L"last_name", lastName);
JsonParseUtils::GetString(*item, L"photo_max", photoMax);
AppLog("Avatar URL %ls", photoMax.GetPointer());
pWebImage = new WebImageView();
pWebImage->Construct(Tizen::Graphics::Rectangle(0, 0, 200, 200), photoMax);
pAvatarPanel->AddControl(pWebImage);
pAvatarPanel->RequestRedraw(true);
pLabelName->SetText(firstName + L" " + lastName);
}
}
示例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: 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);;
//.........这里部分代码省略.........