本文整理汇总了C++中JSONValue::IsArray方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONValue::IsArray方法的具体用法?C++ JSONValue::IsArray怎么用?C++ JSONValue::IsArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONValue
的用法示例。
在下文中一共展示了JSONValue::IsArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: ProcessExcludes
void JSBModule::ProcessExcludes()
{
// excludes
JSONValue root = moduleJSON_->GetRoot();
JSONValue excludes = root.GetChild("excludes");
if (excludes.IsObject())
{
Vector<String> childNames = excludes.GetChildNames();
for (unsigned j = 0; j < childNames.Size(); j++)
{
String classname = childNames.At(j);
JSBClass* klass = GetClass(classname);
if (!klass)
{
ErrorExit("Bad exclude klass");
}
JSONValue classexcludes = excludes.GetChild(classname);
Vector<String> functionNames = classexcludes.GetChildNames();
for (unsigned k = 0; k < functionNames.Size(); k++)
{
JSONValue sig = classexcludes.GetChild(functionNames[k]);
if (!sig.IsArray())
{
ErrorExit("Bad exclude defintion");
}
Vector<String> values;
for (unsigned x = 0; x < sig.GetSize(); x++)
{
values.Push(sig.GetString(x));
}
JSBFunctionSignature* fe = new JSBFunctionSignature(functionNames[k], values);
klass->AddFunctionExclude(fe);
}
}
}
}
示例3: 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);
}
示例4:
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);
}
}
示例5: Load
void JSBModule::Load(const String &moduleJSONFilename)
{
ResourceCache* cache = JSBind::context_->GetSubsystem<ResourceCache>();
JSONFile* moduleJSONFile = cache->GetResource<JSONFile>(moduleJSONFilename);
if (!moduleJSONFile)
{
LOGERRORF("Couldn't load module json: %s", moduleJSONFilename.CString());
ErrorExit("Couldn't load module json");
}
JSONValue moduleJSON = moduleJSONFile->GetRoot();
JSONValue sources = moduleJSON.GetChild("sources");
JSONValue classes = moduleJSON.GetChild("classes");
JSONValue includes = moduleJSON.GetChild("includes");
JSONValue classes_rename = moduleJSON.GetChild("classes_rename");
JSONValue overloads = moduleJSON.GetChild("overloads");
JSONValue requires = moduleJSON.GetChild("requires");
HashMap<String, String> rename;
if (requires.IsArray())
{
for (unsigned j = 0; j < requires.GetSize(); j++)
{
requirements_.Push(requires.GetString(j));
}
}
if (classes_rename.IsObject())
{
Vector<String> childNames = classes_rename.GetValueNames();
for (unsigned j = 0; j < childNames.Size(); j++)
{
String classname = childNames.At(j);
String crename = classes_rename.GetString(classname);
rename[classname] = crename;
}
}
if (includes.IsArray())
{
for (unsigned j = 0; j < includes.GetSize(); j++)
{
includes_.Push(includes.GetString(j));
}
}
if (classes.IsArray())
{
for (unsigned j = 0; j < classes.GetSize(); j++)
{
String classname = classes.GetString(j);
if (rename.Contains(classname))
bindings_->RegisterClass(classname, rename[classname]);
else
bindings_->RegisterClass(classname);
}
}
if (overloads.IsObject())
{
Vector<String> childNames = overloads.GetChildNames();
for (unsigned j = 0; j < childNames.Size(); j++)
{
String classname = childNames.At(j);
JSBClass* klass = bindings_->GetClass(classname);
if (!klass)
{
ErrorExit("Bad overload klass");
}
JSONValue classoverloads = overloads.GetChild(classname);
Vector<String> functionNames = classoverloads.GetChildNames();
for (unsigned k = 0; k < functionNames.Size(); k++)
{
JSONValue sig = classoverloads.GetChild(functionNames[k]);
if (!sig.IsArray())
{
ErrorExit("Bad overload defintion");
}
Vector<String> values;
for (unsigned x = 0; x < sig.GetSize(); x++)
{
values.Push(sig.GetString(x));
}
//.........这里部分代码省略.........
示例6: Load
bool JSBModule::Load(const String& jsonFilename)
{
JSBind* jsbind = GetSubsystem<JSBind>();
LOGINFOF("Loading Module: %s", jsonFilename.CString());
SharedPtr<File> jsonFile(new File(context_, jsonFilename));
if (!jsonFile->IsOpen())
{
LOGERRORF("Unable to open module json: %s", jsonFilename.CString());
return false;
}
moduleJSON_ = new JSONFile(context_);
if (!moduleJSON_->BeginLoad(*jsonFile))
{
LOGERRORF("Unable to parse module json: %s", jsonFilename.CString());
return false;
}
JSONValue root = moduleJSON_->GetRoot();
name_ = root.GetString("name");
JSONValue requires = root.GetChild("requires");
if (requires.IsArray())
{
for (unsigned j = 0; j < requires.GetSize(); j++)
{
requirements_.Push(requires.GetString(j));
}
}
JSONValue classes = root.GetChild("classes");
for (unsigned i = 0; i < classes.GetSize(); i++)
{
classnames_.Push(classes.GetString(i));
}
JSONValue classes_rename = root.GetChild("classes_rename");
if (classes_rename.IsObject())
{
Vector<String> childNames = classes_rename.GetValueNames();
for (unsigned j = 0; j < childNames.Size(); j++)
{
String classname = childNames.At(j);
String crename = classes_rename.GetString(classname);
classRenames_[classname] = crename;
}
}
JSONValue includes = root.GetChild("includes");
if (includes.IsArray())
{
for (unsigned j = 0; j < includes.GetSize(); j++)
{
includes_.Push(includes.GetString(j));
}
}
JSONValue sources = root.GetChild("sources");
for (unsigned i = 0; i < sources.GetSize(); i++)
{
sourceDirs_.Push(sources.GetString(i));
}
if (name_ == "Graphics")
{
#ifdef _MSC_VER
if (jsbind->GetPlatform() == "ANDROID" || jsbind->GetPlatform() == "WEB")
{
sourceDirs_.Push("Source/Atomic/Graphics/OpenGL");
}
else
{
#ifdef ATOMIC_D3D11
sourceDirs_.Push("Source/Atomic/Graphics/Direct3D11");
#else
sourceDirs_.Push("Source/Atomic/Graphics/Direct3D9");
#endif
}
#else
sourceDirs_.Push("Source/Atomic/Graphics/OpenGL");
#endif
}
ScanHeaders();
//.........这里部分代码省略.........