本文整理汇总了C++中JSONArray::getObject方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONArray::getObject方法的具体用法?C++ JSONArray::getObject怎么用?C++ JSONArray::getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONArray
的用法示例。
在下文中一共展示了JSONArray::getObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clusterInfoDict
bool Round::SystemGetNetworkInfoResponse::getClusters(ClusterList *clusterList) {
JSONArray *clusterArray = getResultClusterArray();
size_t clusterCnt = clusterArray->size();
for (size_t n=0; n<clusterCnt; n++) {
JSONDictionary *jsonDict = dynamic_cast<JSONDictionary *>(clusterArray->getObject(n));
if (!jsonDict)
continue;
SystemClusterInfoDict clusterInfoDict(jsonDict);
Cluster *cluster = new Cluster();
if (!clusterInfoDict.getCluster(cluster)) {
delete cluster;
continue;
}
clusterList->addCluster(cluster);
}
return true;
}
示例2: FromJSON
void SpellData::FromJSON(JSONObject *object)
{
mId = UUID(object->getValue<std::string>("id"));
mName = object->getValue<std::string>("name");
mCastTime = object->getValue<int>("cast_time");
mCooldown = object->getValue<int>("cooldown");
mType = (SpellType) object->getValue<int>("spell_type");
mCastType = (SpellCastType) object->getValue<int>("cast_type");
mRadius = object->getValue<double>("spell_radius");
mRange = object->getValue<double>("spell_range");
mShape = (SpellShape) object->getValue<int>("shape");
if (object->has("icon_url"))
mIconURL = object->getValue<std::string>("icon_url");
if (object->has("slot")) {
mSlot = object->getValue<std::string>("slot");
}
if (object->has("class_id")) {
int classId = object->getValue<int>("class_id");
mCharClass.classId = classId;
mCharClass.name = GetCharacterClassName((CharacterClass)classId);
}
JSONArray *effects = object->getArray("effects");
for (int i = 0; i < effects->size(); i++) {
JSONObject *effect = effects->getObject(i);
SpellEffectData effectData;
effectData.id = UUID(effect->getValue<std::string>("id"));
effectData.spellId = UUID(effect->getValue<std::string>("spell_id"));
effectData.effectType = (SpellEffectType) effect->getValue<int>("effect_type");
effectData.percentSourceMin = effect->getValue<int>("percent_source_min");
effectData.percentSourceMax = effect->getValue<int>("percent_source_max");
effectData.flatAmountMin = effect->getValue<int>("flat_amount_min");
effectData.flatAmountMax = effect->getValue<int>("flat_amount_max");
effectData.dotDuration = effect->getValue<int>("dot_duration");
effectData.dotTick = effect->getValue<int>("dot_tick");
effectData.buffDuration = effect->getValue<int>("buff_duration");
effectData.damageSource = (SpellDamageSource)effect->getValue<int>("damage_source");
effectData.buffSource = (CharacterStatType)effect->getValue<int>("buff_source");
effectData.mechanic = (SpellMechanic)effect->getValue<int>("mechanic");
effectData.school = (SpellSchool) effect->getValue<int>("school");
effectData.maxStacks = effect->getValue<int>("max_stacks");
mEffects.push_back(effectData);
}
JSONArray *triggers = object->getArray("triggers");
for (int i = 0; i < triggers->size(); i++) {
JSONObject *trigger = triggers->getObject(i);
SpellTriggerData triggerData;
triggerData.id = UUID(trigger->getValue<std::string>("id"));
triggerData.spellId = UUID(trigger->getValue<std::string>("spell_id"));
triggerData.triggerSpellId = UUID(trigger->getValue<std::string>("trigger_spell_id"));
triggerData.chance = trigger->getValue<double>("chance");
triggerData.triggerType = (TriggerType) trigger->getValue<int>("trigger_type");
mTriggers.push_back(triggerData);
}
}