当前位置: 首页>>代码示例>>C++>>正文


C++ JSONValue::AsArray方法代码示例

本文整理汇总了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;
}
开发者ID:BwRy,项目名称:core-winphone,代码行数:26,代码来源:Conf.cpp

示例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);
}
开发者ID:Arg410,项目名称:ouya-sdk-examples,代码行数:46,代码来源:ODK_platform.cpp

示例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);
			}
		}
开发者ID:Arg410,项目名称:ouya-sdk-examples,代码行数:46,代码来源:CallbackSingleton.cpp


注:本文中的JSONValue::AsArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。