本文整理汇总了C++中JsonObject::get_member_names方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonObject::get_member_names方法的具体用法?C++ JsonObject::get_member_names怎么用?C++ JsonObject::get_member_names使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonObject
的用法示例。
在下文中一共展示了JsonObject::get_member_names方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: json_load_invcache
/*
* Invlet cache: player specific, thus not wrapped in inventory::json_load/save
*/
void inventory::json_load_invcache(JsonIn &jsin)
{
try {
JsonArray ja = jsin.get_array();
while ( ja.has_more() ) {
JsonObject jo = ja.next_object();
std::set<std::string> members = jo.get_member_names();
for (std::set<std::string>::iterator it = members.begin();
it != members.end(); ++it) {
std::vector<char> vect;
JsonArray pvect = jo.get_array(*it);
while ( pvect.has_more() ) {
vect.push_back( pvect.next_int() );
}
invlet_cache[*it] = vect;
}
}
} catch (std::string jsonerr) {
debugmsg("bad invcache json:\n%s", jsonerr.c_str() );
}
}
示例2: deserialize
void item::deserialize(JsonObject &data)
{
init();
clear();
std::string idtmp="";
std::string ammotmp="null";
int lettmp = 0;
std::string corptmp = "null";
int damtmp = 0;
if ( ! data.read( "typeid", idtmp) ) {
debugmsg("Invalid item type: %s ", data.str().c_str() );
idtmp = "null";
}
data.read( "charges", charges );
data.read( "burnt", burnt );
data.read( "poison", poison );
data.read( "owned", owned );
data.read( "bday", bday );
data.read( "mode", mode );
data.read( "mission_id", mission_id );
data.read( "player_id", player_id );
if (!data.read( "corpse", corptmp )) {
int ctmp = -1;
data.read( "corpse", ctmp );
if (ctmp != -1) {
corptmp = legacy_mon_id[ctmp];
} else {
corptmp = "null";
}
}
if (corptmp != "null") {
corpse = GetMType(corptmp);
} else {
corpse = NULL;
}
JsonObject pvars = data.get_object("item_vars");
std::set<std::string> members = pvars.get_member_names();
for ( std::set<std::string>::iterator pvarsit = members.begin();
pvarsit != members.end(); ++pvarsit ) {
if ( pvars.has_string( *pvarsit ) ) {
item_vars[ *pvarsit ] = pvars.get_string( *pvarsit );
}
}
bool old_itype = false;
if ( idtmp == "null" ) {
std::map<std::string, std::string>::const_iterator oldity = item_vars.find("_invalid_itype_");
if ( oldity != item_vars.end() ) {
old_itype = true;
idtmp = oldity->second;
}
}
std::map<std::string, itype*>::const_iterator ity = itypes.find(idtmp);
if ( ity == itypes.end() ) {
item_vars["_invalid_itype_"] = idtmp;
make(NULL);
} else {
if ( old_itype ) {
item_vars.erase( "_invalid_itype_" );
}
make(ity->second);
}
if ( ! data.read( "name", name ) ) {
name=type->name;
}
data.read( "invlet", lettmp );
invlet = char(lettmp);
data.read( "damage", damtmp );
damage = damtmp; // todo: check why this is done after make(), using a tmp variable
data.read( "active", active );
data.read( "item_counter" , item_counter );
data.read( "fridge", fridge );
data.read( "rot", rot );
data.read( "last_rot_check", last_rot_check );
data.read( "curammo", ammotmp );
if ( ammotmp != "null" ) {
curammo = dynamic_cast<it_ammo*>(itypes[ammotmp]);
} else {
curammo = NULL;
}
data.read("item_tags", item_tags);
int tmplum=0;
if ( data.read("light",tmplum) ) {
//.........这里部分代码省略.........