本文整理汇总了C++中JSONValue::AsArray方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONValue::AsArray方法的具体用法?C++ JSONValue::AsArray怎么用?C++ JSONValue::AsArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONValue
的用法示例。
在下文中一共展示了JSONValue::AsArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseAction
BOOL WINAPI Conf::ParseAction(JSONArray js) {
UINT i = 0;
ActionsManager *actionsManager = ActionsManager::self();
for (i = 0; i < js.size(); i++) {
JSONObject jo = js[i]->AsObject();
JSONValue *c = jo[L"subactions"];
if (c == NULL || c->IsArray() == FALSE) {
// WARNING
continue;
}
#ifdef _DEBUG
WCHAR msg[128];
wstring moduleName = jo[L"desc"]->AsString();
//wprintf(L"Parsing Action: \"%s\"\n", moduleName.c_str());
swprintf_s(msg, L"Parsing Action: \"%s\"\n", moduleName.c_str());OutputDebugString(msg);
#endif
actionsManager->add(i, c->AsArray());
}
return TRUE;
}
示例2: OuyaPlugin_asyncOuyaRequestProducts
void OuyaPlugin_asyncOuyaRequestProducts(const char* productsJson, s3eCallback onSuccess, s3eCallback onFailure, s3eCallback onCancel)
{
IwTrace(ODK, ("ODK_platform: OuyaPlugin_asyncOuyaRequestProducts"));
std::string msg = "OuyaPlugin_asyncOuyaRequestProducts: productsJson=";
msg.append(productsJson);
IwTrace(ODK, (msg.c_str()));
//convert JSON to product id array
// Parse example data
JSONValue* value = JSON::Parse(productsJson);
if (value == NULL)
{
IwTrace(ODK, ("Parsing JSON Failed"));
return;
}
if (!value->IsArray())
{
IwTrace(ODK, ("Parsing JSON Failed: Not an array"));
return;
}
// Retrieve the main object
JSONArray data = value->AsArray();
std::vector<std::string> productIds;
for (unsigned int i = 0; i < data.size(); i++)
{
if (data[i]->IsString())
{
const std::wstring wstr = data[i]->AsString();
std::string productId( wstr.begin(), wstr.end() );
productIds.push_back(productId);
}
}
OuyaSDK::CallbackSingleton::GetInstance()->m_callbacksRequestProducts->RegisterCallbacks(onSuccess, onFailure, onCancel);
g_pluginOuya.AsyncOuyaRequestProducts(productIds);
}
示例3:
JNIEXPORT void JNICALL Java_tv_ouya_sdk_android_CallbacksRequestReceipts_CallbacksRequestReceiptsOnSuccess(JNIEnv* env, jobject thiz, jstring jsonData)
{
LOGI("***********Java_tv_ouya_sdk_android_CallbacksRequestReceipts_CallbacksRequestReceiptsOnSuccess***********");
std::string strJsonData = env->GetStringUTFChars(jsonData, NULL);
//char buffer[256];
//sprintf(buffer, "Java_tv_ouya_sdk_android_CallbacksRequestReceipts_CallbacksRequestReceiptsOnSuccess: Returned to C: %s", strJsonData.c_str());
//LOGI(buffer);
//LOGI("Parsing JSON Data");
// Parse example data
JSONValue* value = JSON::Parse(strJsonData.c_str());
if (value == NULL)
{
LOGI("Parsing JSON Failed");
return;
}
if (!value->IsArray())
{
LOGI("Parsing JSON Failed: Not an array");
return;
}
// Retrieve the main object
JSONArray data = value->AsArray();
std::vector<Receipt> receipts;
for (unsigned int i = 0; i < data.size(); i++)
{
OuyaSDK::Receipt newReceipt;
newReceipt.ParseJSON(data[i]);
receipts.push_back(newReceipt);
}
CallbacksRequestReceipts* callback = CallbackSingleton::GetInstance()->m_callbacksRequestReceipts;
if (callback)
{
callback->OnSuccess(receipts);
}
}