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


C++ JSONValue类代码示例

本文整理汇总了C++中JSONValue的典型用法代码示例。如果您正苦于以下问题:C++ JSONValue类的具体用法?C++ JSONValue怎么用?C++ JSONValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了JSONValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SaveSettingsInternal

bool ModelImporter::SaveSettingsInternal()
{
    if (!AssetImporter::SaveSettingsInternal())
        return false;

    JSONValue save = jsonRoot_.CreateChild("ModelImporter");

    save.SetFloat("scale", scale_);
    save.SetBool("importAnimations", importAnimations_);

    JSONValue animInfo = save.CreateChild("animInfo", JSON_ARRAY);

    for (unsigned i = 0; i < animationInfo_.Size(); i++)
    {
        const SharedPtr<AnimationImportInfo>& info = animationInfo_[i];
        JSONValue jinfo = animInfo.CreateChild();
        jinfo.SetString("name", info->GetName());
        jinfo.SetFloat("startTime", info->GetStartTime());
        jinfo.SetFloat("endTime", info->GetEndTime());
    }

    return true;
}
开发者ID:WorldofOpenDev,项目名称:AtomicGameEngine,代码行数:23,代码来源:ModelImporter.cpp

示例2: Java_tv_ouya_sdk_android_CallbacksRequestPurchase_CallbacksRequestPurchaseOnSuccess

		JNIEXPORT void JNICALL Java_tv_ouya_sdk_android_CallbacksRequestPurchase_CallbacksRequestPurchaseOnSuccess(JNIEnv* env, jobject thiz, jstring jsonData)
		{
			//LOGI("***********Java_tv_ouya_sdk_android_CallbacksRequestPurchase_CallbacksRequestPurchaseOnSuccess***********");
		
			std::string strJsonData = env->GetStringUTFChars(jsonData, NULL);

			//char buffer[256];
			//sprintf(buffer, "Java_tv_ouya_sdk_android_CallbacksRequestPurchase_CallbacksRequestPurchaseOnSuccess: Returned to C: %s", strJsonData.c_str());
			//LOGI(buffer);

			// Parse example data
			JSONValue* value = JSON::Parse(strJsonData.c_str());

			if (value == NULL)
			{
				LOGI("Parsing JSON Failed");
				return;
			}

			if (!value->IsObject())
			{
				LOGI("Parsing JSON Failed: Not an object");
				return;
			}

			// Retrieve the main object
			JSONValue data = value->AsObject();

			OuyaSDK::Product product;
			product.ParseJSON(&data);
		
			CallbacksRequestPurchase* callback = CallbackSingleton::GetInstance()->m_callbacksRequestPurchase;
			if (callback)
			{
				callback->OnSuccess(product);
			}
		}
开发者ID:Arg410,项目名称:ouya-sdk-examples,代码行数:37,代码来源:CallbackSingleton.cpp

示例3: GetDotAssetFilename

// load .asset
bool Asset::Load()
{
    FileSystem* fs = GetSubsystem<FileSystem>();
    AssetDatabase* db = GetSubsystem<AssetDatabase>();

    String assetFilename = GetDotAssetFilename();

    SharedPtr<File> file(new File(context_, assetFilename));
    json_ = new JSONFile(context_);
    json_->Load(*file);
    file->Close();

    JSONValue root = json_->GetRoot();

    assert(root.Get("version").GetInt() == ASSET_VERSION);

    guid_ = root.Get("guid").GetString();

    db->RegisterGUID(guid_);

    dirty_ = false;
    if (!CheckCacheFile())
    {
        LOGINFOF("CheckCacheFile:false - %s", path_.CString());
        dirty_ = true;
    }

    // handle import

    if (importer_.NotNull())
        importer_->LoadSettings(root);

    json_ = 0;

    return true;

}
开发者ID:T4RDISDev,项目名称:AtomicGameEngine,代码行数:38,代码来源:Asset.cpp

示例4: GetPreferencesPath

    bool AEEditorPrefs::ReadPreferences(VariantMap& engineParameters)
    {
        String path = GetPreferencesPath();

        JSONValue prefs;

        LoadPreferences(prefs);

        if (!prefs.IsObject() || !prefs["editorWindow"].IsObject())
        {
            if (!CreateDefaultPreferences(path, prefs))
                return false;
        }

        JSONValue& editorWindow = prefs["editorWindow"];

        engineParameters["WindowPositionX"] = editorWindow["x"].GetUInt();
        engineParameters["WindowPositionY"] = editorWindow["y"].GetUInt();
        engineParameters["WindowWidth"] = editorWindow["width"].GetUInt();
        engineParameters["WindowHeight"] = editorWindow["height"].GetUInt();
        engineParameters["WindowMaximized"] = editorWindow["maximized"].GetBool();

        return true;
    }
开发者ID:LumaDigital,项目名称:AtomicGameEngine,代码行数:24,代码来源:AEEditorPrefs.cpp

示例5: InspectAssembly

bool NETToolSystem::InspectAssembly(const String& pathToAssembly, JSONValue &json)
{
    json.SetType(JSON_NULL);

    if (!inspectAssemblyFunction_)
        return false;

    String jsonString = inspectAssemblyFunction_(pathToAssembly.CString());

    if (!jsonString.Length())
        return false;

    return JSONFile::ParseJSON(jsonString, json);

}
开发者ID:Drooids,项目名称:AtomicGameEngine,代码行数:15,代码来源:NETToolSystem.cpp

示例6: Write

void IOSBuildSettings::Write(JSONValue& parent)
{
    JSONValue json;

    json.Set("appName", appName_);
    json.Set("packageName", packageName_);
    json.Set("companyName", companyName_);
    json.Set("productName", productName_);

    json.Set("provisionFile", provisionFile_);
    json.Set("appIDPrefix", appidPrefix_);

    parent.Set("IOSBuildSettings", json);

}
开发者ID:EternalXY,项目名称:AtomicGameEngine,代码行数:15,代码来源:ProjectBuildSettings.cpp

示例7: Read

void WebBuildSettings::Read(JSONValue& parent)
{
    JSONValue json = parent.Get("WebBuildSettings");

    if (!json.IsObject())
        return;

    appName_ = json.Get("appName").GetString();
    packageName_ = json.Get("packageName").GetString();
    companyName_ = json.Get("companyName").GetString();
    productName_ = json.Get("productName").GetString();

}
开发者ID:EternalXY,项目名称:AtomicGameEngine,代码行数:13,代码来源:ProjectBuildSettings.cpp

示例8: createJSON

bool HGESurrogate::createJSON(JSONValue& json, bool firstResponder)
{
	bool didCreate = 0;
	
	if (json.IsObject()) {
		if (firstResponder) {
			JSONValue& substitution = json[JSON_SUBSTITUTION_DECLARATION];
			if (!substitution.IsUndefined())
			{
				this->carry(substitution);
				didCreate = !0;
				firstResponder = 0;
			}
		}
		
		
	}
	
	return didCreate;
}
开发者ID:jcmoore,项目名称:ggframework,代码行数:20,代码来源:HGESurrogate.cpp

示例9: exception

JSONObject Configuration::getObjectFromArray(const wstring& arrayName, const wstring& field) {
	JSONValue *c = json[arrayName];

	if (c == NULL || c->IsObject() == FALSE) {
		throw new exception();
	}

	JSONObject arr = c->AsObject();
	JSONValue *val = arr[field];

	if (val == NULL || val->IsObject() == FALSE) {
		throw new exception();
	}

	return val->AsObject();
}
开发者ID:BwRy,项目名称:core-winmobile,代码行数:16,代码来源:Configuration.cpp

示例10: LoadJSON

bool ObjectAnimation::LoadJSON(const JSONValue& source)
{
    attributeAnimationInfos_.Clear();

    JSONValue attributeAnimationsValue = source.Get("attributeanimations");
    if (attributeAnimationsValue.IsNull())
        return true;
    if (!attributeAnimationsValue.IsObject())
        return true;

    const JSONObject& attributeAnimationsObject = attributeAnimationsValue.GetObject();

    for (JSONObject::ConstIterator it = attributeAnimationsObject.Begin(); it != attributeAnimationsObject.End(); it++)
    {
        String name = it->first_;
        JSONValue value = it->second_;
        SharedPtr<ValueAnimation> animation(new ValueAnimation(context_));
        if (!animation->LoadJSON(value))
            return false;

        String wrapModeString = value.Get("wrapmode").GetString();
        WrapMode wrapMode = WM_LOOP;
        for (int i = 0; i <= WM_CLAMP; ++i)
        {
            if (wrapModeString == wrapModeNames[i])
            {
                wrapMode = (WrapMode)i;
                break;
            }
        }

        float speed = value.Get("speed").GetFloat();
        AddAttributeAnimation(name, animation, wrapMode, speed);
    }

    return true;
}
开发者ID:03050903,项目名称:Urho3D,代码行数:37,代码来源:ObjectAnimation.cpp

示例11: Load

bool ResourceMapRouter::Load(const JSONValue& json)
{
    const JSONValue& assetMap = json.Get("assetMap");

    if (!assetMap.IsObject())
        return false;

    ConstJSONObjectIterator itr = assetMap.Begin();
    while (itr != assetMap.End())
    {
        StringVector tags = itr->first_.Split(';');

        if (tags.Size() == 2)
        {
            resourceMap_[tags[0]][tags[1]] = itr->second_.GetString();
        }

        itr++;
    }

    return true;
}
开发者ID:Type1J,项目名称:AtomicGameEngine,代码行数:22,代码来源:ResourceMapRouter.cpp

示例12: save

  void QuizSubmission::save(QuizQuestion const* qq,
                            JSONValue &document,
                            Session &session,
                            AsyncCallback callback) const {
    document["validation_token"] = validationToken();
    document["attempt"] = attempt();
    document["access_code"] = mQuiz->accessCode();

    session.put(qq->answerUrl(*this),
      document.toStyledString(),
      [&, callback](bool success, HTTP::Response response) {
        if (!success) {
          if (callback) {
            callback(false);
          }
          return;
        }

        if (callback) {
          callback(true);
        }
      });
  }
开发者ID:amireh,项目名称:libcanvas,代码行数:23,代码来源:quiz_submission.cpp

示例13: SaveJSON

bool ObjectAnimation::SaveJSON(JSONValue& dest) const
{
    JSONValue attributeAnimationsValue;

    for (HashMap<String, SharedPtr<ValueAnimationInfo> >::ConstIterator i = attributeAnimationInfos_.Begin();
         i != attributeAnimationInfos_.End(); ++i)
    {
        JSONValue animValue;
        animValue.Set("name", i->first_);

        const ValueAnimationInfo* info = i->second_;
        if (!info->GetAnimation()->SaveJSON(animValue))
            return false;

        animValue.Set("wrapmode", wrapModeNames[info->GetWrapMode()]);
        animValue.Set("speed", (float) info->GetSpeed());

        attributeAnimationsValue.Set(i->first_, animValue);
    }

    dest.Set("attributeanimations", attributeAnimationsValue);
    return true;
}
开发者ID:03050903,项目名称:Urho3D,代码行数:23,代码来源:ObjectAnimation.cpp

示例14: SaveJSON

bool Animatable::SaveJSON(JSONValue& dest) const
{
    if (!Serializable::SaveJSON(dest))
        return false;

    // Object animation without name
    if (objectAnimation_ && objectAnimation_->GetName().Empty())
    {
        JSONValue objectAnimationValue;
        if (!objectAnimation_->SaveJSON(objectAnimationValue))
            return false;
        dest.Set("objectanimation", objectAnimationValue);
    }

    JSONValue attributeAnimationValue;

    for (HashMap<String, SharedPtr<AttributeAnimationInfo> >::ConstIterator i = attributeAnimationInfos_.Begin();
         i != attributeAnimationInfos_.End(); ++i)
    {
        ValueAnimation* attributeAnimation = i->second_->GetAnimation();
        if (attributeAnimation->GetOwner())
            continue;

        const AttributeInfo& attr = i->second_->GetAttributeInfo();
        JSONValue attributeValue;
        attributeValue.Set("name", attr.name_);
        if (!attributeAnimation->SaveJSON(attributeValue))
            return false;

        attributeValue.Set("wrapmode", wrapModeNames[i->second_->GetWrapMode()]);
        attributeValue.Set("speed", (float) i->second_->GetSpeed());

        attributeAnimationValue.Set(attr.name_, attributeValue);
    }

    return true;
}
开发者ID:dreamsxin,项目名称:Urho3D,代码行数:37,代码来源:Animatable.cpp

示例15: switch

JSONValue::JSONValue(const JSONValue &v) {
  m_type = v.getType();

  switch (m_type) {
  case JSONValue::NULLTYPE:
    break; // nothing to do
  case JSONValue::BOOL:
    if (!v.getValue(m_bool))
      throw(JSONCopyException("Failed to copy boolean"));
    break;
  case JSONValue::NUMBER:
    if (!v.getValue(m_num))
      throw(JSONCopyException("Failed to copy float"));
    break;
  case JSONValue::STRING:
    mp_string = new string;
    if (!v.getValue(*mp_string)) {
      delete mp_string; // Make sure we don't leak memory in the event of a
                        // failure
      throw(JSONCopyException("Failed to copy string"));
    }
    break;
  case JSONValue::ARRAY:
    mp_array = new JSONArray;
    if (!v.getValue(*mp_array)) {
      delete mp_array;
      throw(JSONCopyException("Failed to copy array"));
    }
    break;
  case JSONValue::OBJECT:
    mp_object = new JSONObject;
    if (!v.getValue(*mp_object)) {
      delete mp_object;
      throw(JSONCopyException("Failed to copy object"));
    }
    break;
  default:
    // Should never hit this!
    throw(JSONCopyException("Unknown JSON type!!"));
  }
}
开发者ID:liyulun,项目名称:mantid,代码行数:41,代码来源:SimpleJSON.cpp


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