本文整理汇总了C++中JsonObject::GetMapEnumeratorN方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonObject::GetMapEnumeratorN方法的具体用法?C++ JsonObject::GetMapEnumeratorN怎么用?C++ JsonObject::GetMapEnumeratorN使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonObject
的用法示例。
在下文中一共展示了JsonObject::GetMapEnumeratorN方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
//.........这里部分代码省略.........