本文整理汇总了C++中json::Value::getMemberNames方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::getMemberNames方法的具体用法?C++ Value::getMemberNames怎么用?C++ Value::getMemberNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类json::Value
的用法示例。
在下文中一共展示了Value::getMemberNames方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: jsonParse
int jsonParse(string _s)
{
// Let's parse it
Json::Value root;
Json::Reader reader;
bool parsedSuccess = reader.parse(_s,
root,
false);
if (not parsedSuccess) {
// Report failures and their locations
// in the document.
cout << "Failed to parse JSON" << endl
<< reader.getFormatedErrorMessages()
<< endl;
return 1;
}
Json::Value::Members mem = root.getMemberNames();
Json::Value child = root[mem[0]];
cout << "name: " << mem[0] << ", child: " << child.asString() << endl;
for (int i = 1; i < mem.size(); ++i)
{
child = root[mem[i]];
cout << "name: " << mem[i] << endl;
Json::Value::Members childMem = child.getMemberNames();
cout << "\t" << "type: " << child[childMem[0]].asString() << endl;
cout << "\t" << "value: " << child[childMem[1]].asString() << endl;
cout << "\t" << "typeGen: " << child[childMem[2]].asString() << endl;
}
return 1;
}
示例2: load
//Load skin
bool Skin::load(const std::string& filename) {
std::ifstream ifs(filename);
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
Json::Value root;
Json::Reader reader;
m_classes.clear();
if (!reader.parse(str, root)) {
return false;
}
Json::Value::Members classes = root.getMemberNames();
for (uint32 i = 0; i < classes.size(); i++) {
std::string name = classes[i];
Json::Value v = root[name];
Skin::SkinClass sc;
bool addP = false;
//We need to figure out if we're dealing with sub classes.
Json::Value::Members subs = v.getMemberNames();
for (uint32 j = 0; j < subs.size(); j++) {
if (subs[j] != "normal" && subs[j] != "hover" && subs[j] != "active" && subs[j] != "focus") {
//Yup, this is a sub class.
Skin::SkinClass sub;
jsonToStates(v[subs[j]], sub);
sc.m_subs.insert(ClassMapPair(subs[j], sub));
} else {
addP = true;
}
}
//There's a valid state in the root
if (addP) {
jsonToStates(v, sc);
}
sc.reset();
m_classes.insert(ClassMapPair(name, sc));
}
m_loaded = filename;
return true;
}
示例3: load_card_right_json
int CCardFieldDlg::load_card_right_json()
{
int i,idx;
Json::Value root;
Json::Reader reader;
std::ifstream input;
//input.open("e:\\works\\cardlib\\ykt.v3_1.dev\\bin\\lcsmanager\\cardright.json");
input.open((LPCTSTR)m_jsonfile);
if(input.is_open()==false)
{
AfxMessageBox("´ò¿ªÅäÖÃÎļþ´íÎó");
return -1;
}
if(reader.parse(input,root)==false)
{
std::string msg = "¶ÁÈ¡ÅäÖÃÎļþ´íÎó : " + reader.getFormatedErrorMessages();
AfxMessageBox(msg.c_str());
return -1;
}
std::string encoding = root.get("encoding","GBK").asString();
Json::Value fields = root["cardfield"];
Json::Value::Members fldid = fields.getMemberNames();
m_cardfield.clear();
for(i = 0;i < fldid.size();++i)
{
idx = atoi(fldid[i].c_str());
std::string v = fields.get(fldid[i],"Unknown").asString();
m_cardfield.insert(CARD_FILED_MAP::value_type(idx,v));
}
if(fldid.size() > m_string_len)
m_string_len = fldid.size();
// std::sort(m_cardfield.begin(),m_cardfield.end());
init_check_box();
return 0;
}
示例4: importParameters
void JsonParameters::importParameters(Json::Value parametersImport)
{
if (parametersImport.isObject()) {
Json::Value::Members members = parametersImport.getMemberNames();
Json::Value::Members::iterator it;
for (it=members.begin(); it!=members.end(); it++) {
string name = *it;
JsonParameter *parameter = getParameter(name);
if (parameter != NULL) {
if (parameter->canDeserialize(parametersImport[name])) {
parameter->deserialize(parametersImport[name]);
} else {
std::cerr << "Can't load parameter " << name << std::endl;
}
} else {
std::cerr << "Non-existent parameter: " << name << std::endl;
}
}
} else {
if (!parametersImport.isNull()) {
std::cerr << "Parameters values should be an object" << std::endl;
}
}
}
示例5:
/**
* Constructor
* @param equipletID identifier for the equiplet
* @param moduleID identifier for the deltarobot
**/
stewartGoughNodeNamespace::StewartGoughNode::StewartGoughNode(std::string equipletName, rexos_datatypes::ModuleIdentifier moduleIdentifier) :
rexos_module::ActorModule::ActorModule(equipletName, moduleIdentifier),
stewartGough(NULL),
lastX(0.0),
lastY(0.0),
lastZ(0.0){
REXOS_INFO("StewartGoughNode Constructor entering...");
// get the properties and combine them for the deltarobot
std::string properties = this->getModuleProperties();
std::string typeProperties = this->getModuleTypeProperties();
Json::Reader reader;
Json::Value jsonNode;
Json::Value typeJsonNode;
reader.parse(properties, jsonNode);
reader.parse(typeProperties, typeJsonNode);
std::vector<std::string> typeJsonNodeMemberNames = typeJsonNode.getMemberNames();
for(int i = 0; i < typeJsonNodeMemberNames.size(); i++) {
jsonNode[typeJsonNodeMemberNames[i]] = typeJsonNode[typeJsonNodeMemberNames[i]];
}
Json::StyledWriter writer;
ROS_INFO("%s", writer.write(jsonNode).c_str());
// Create a stewart gough robot
stewartGough = new rexos_stewart_gough::StewartGough(jsonNode);
}
示例6: Address
StateLoader::StateLoader(Json::Value const& _json, std::string const& _dbPath):
m_state(State::openDB(_dbPath, WithExisting::Kill), BaseState::Empty)
{
for (string const& name: _json.getMemberNames())
{
Json::Value o = _json[name];
Address address = Address(name);
bytes code = fromHex(o["code"].asString().substr(2));
if (!code.empty())
{
m_state.m_cache[address] = Account(u256(o["balance"].asString()), Account::ContractConception);
m_state.m_cache[address].setCode(std::move(code));
}
else
m_state.m_cache[address] = Account(u256(o["balance"].asString()), Account::NormalCreation);
for (string const& j: o["storage"].getMemberNames())
m_state.setStorage(address, u256(j), u256(o["storage"][j].asString()));
for (auto i = 0; i < u256(o["nonce"].asString()); ++i)
m_state.noteSending(address);
m_state.ensureCached(address, false, false);
}
m_state.commit();
}
示例7: Load
void SceneLoader::Load(const char* strFileName, GameObject *rootGameObject)
{
GameObject *pGo = 0;
Json::Value root;
Json::Reader reader;
const char* jsonText = ReadFileIntoString( strFileName );
if( !reader.parse( jsonText, root ) )
{
return;
}
Json::Value componentsVal = root["objects"];
int componentCount = componentsVal.size();
for( int i=0; i< componentCount; ++i )
{
Json::Value componentVal = componentsVal[i];
Json::Value::Members members = componentVal.getMemberNames();
std::map<std::string, std::string> mapParams;
for( Json::Value::Members::iterator it = members.begin(); it != members.end(); ++it)
{
std::string memberName = *it;
std::string value = componentVal[memberName].asString();
mapParams[memberName] = value;
}
CreateSceneObject( rootGameObject, mapParams );
}
}
示例8: parseEmailForInbox
void emailExtraction::parseEmailForInbox(Json::Value value, std::string folder) {
Json::Value directoryObj = value[folder];
std::vector<std::string> objNames = directoryObj.getMemberNames();
for (unsigned int i = 0; i < directoryObj.size(); i++) {
auto contentObj = directoryObj[objNames[i]];
std::string objName = objNames[i];
if(contentObj.size() > 0) {
parseEmailForInbox(directoryObj, objNames[i]);
}
else {
std::string content = directoryObj[objNames[i]].asString();
//std::cout << objName+""+content << std::endl;
if(objName == "Subject") {
addSubject(content);
}
else if(objName == "To") {
addTo(content);
}
else if(objName == "From") {
addFrom(content);
}
else if(objName == "Body") {
addBody(content);
}
else if(objName == "Visible") {
addVisible(content.at(0) == '1');
}
else {
std::cout << "ERROR" << std::endl;
}
}
}
}
示例9: extractOptions
Options PipelineReaderJSON::extractOptions(Json::Value& node)
{
Options options;
for (const std::string& name : node.getMemberNames())
{
if (node[name].isString())
options.add(name, node[name].asString());
else if (node[name].isInt())
options.add(name, node[name].asInt64());
else if (node[name].isUInt())
options.add(name, node[name].asUInt64());
else if (node[name].isDouble())
options.add(name, node[name].asDouble());
else if (node[name].isBool())
options.add(name, node[name].asBool());
else if (node[name].isNull())
options.add(name, "");
else
throw pdal_error("JSON pipeline: Value of stage option '" +
name + "' cannot be converted.");
}
node.clear();
return options;
}
示例10: loadJSONFile
RegexpData::RegexpData() {
Json::Value root = loadJSONFile(RegexpData::REGEXPS_FILE);
for(const auto& key: root.getMemberNames()) {
m_regexpMap[key] = root[key].asString();
}
}
示例11: assembleRecord
RecordPtr Common::assembleRecord(const Json::Value& rVal)
{
auto contact = rVal["contact"].asString();
auto nonce = rVal["nonce"].asString();
auto pow = rVal["pow"].asString();
auto pubHSKey = rVal["pubHSKey"].asString();
auto sig = rVal["recordSig"].asString();
auto type = rVal["type"].asString();
auto name = rVal["name"].asString();
if (type != "Create")
Log::get().error("Record parsing: not a Create Record!");
NameList subdomains;
if (rVal.isMember("subd"))
{
Json::Value list = rVal["subd"];
auto sources = list.getMemberNames();
for (auto source : sources)
subdomains.push_back(std::make_pair(source, list[source].asString()));
}
auto key = Utils::base64ToRSA(pubHSKey);
return std::make_shared<CreateR>(contact, name, subdomains, nonce, pow, sig,
key);
}
示例12: StartListeningForTransactionUpdates
//---------------------------------------------------------------
//---------------------------------------------------------------
void GooglePlayIAPJavaInterface::StartListeningForTransactionUpdates(const CSNetworking::IAPSystem::TransactionStatusDelegate& in_delegate)
{
CS_ASSERT(in_delegate != nullptr, "Cannot have null transaction delegate");
m_transactionStatusDelegate = in_delegate;
JNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();
env->CallVoidMethod(GetJavaObject(), GetMethodID("RestorePendingUnmanagedTransactions"));
Json::Value jData;
if(CSCore::JsonUtils::ReadJson(CSCore::StorageLocation::k_cache, k_pendingCacheFile, jData))
{
const Json::Value::Members& members = jData.getMemberNames();
jobjectArray transactionIDs = env->NewObjectArray(members.size(), env->FindClass("java/lang/String"), env->NewStringUTF(""));
u32 index = 0;
for(Json::Value::Members::const_iterator it = members.begin(); it != members.end(); ++it, ++index)
{
jstring jtransactionId = JavaInterfaceUtils::CreateJStringFromSTDString(*it);
env->SetObjectArrayElement(transactionIDs, index, jtransactionId);
env->DeleteLocalRef(jtransactionId);
}
env->CallVoidMethod(GetJavaObject(), GetMethodID("RestorePendingManagedTransactions"), transactionIDs);
env->DeleteLocalRef(transactionIDs);
}
}
示例13: mergeJsonNode
void EnvironmentCache::mergeJsonNode(Json::Value& toBeMerged, Json::Value& mergeTarget) {
#ifdef ENVIRONMENT_CACHE_DEBUG
ROS_DEBUG_STREAM("Merging json nodes, toBeMerged: " << toBeMerged << " mergeTerget: " << mergeTarget);
#endif
std::vector<std::string> memberNames = toBeMerged.getMemberNames();
for(int i = 0; i < memberNames.size(); i++) {
#ifdef ENVIRONMENT_CACHE_DEBUG
ROS_DEBUG_STREAM("Merging member " << memberNames[i]);
#endif
if(toBeMerged[memberNames[i]].type() == Json::ValueType::objectValue) {
#ifdef ENVIRONMENT_CACHE_DEBUG
ROS_DEBUG_STREAM("Member is JsonObject");
#endif
mergeJsonNode(toBeMerged[memberNames[i]], mergeTarget[memberNames[i]]);
} else {
#ifdef ENVIRONMENT_CACHE_DEBUG
ROS_DEBUG_STREAM("Member is not JsonObject");
#endif
mergeTarget[memberNames[i]] = toBeMerged[memberNames[i]];
}
}
#ifdef ENVIRONMENT_CACHE_DEBUG
ROS_DEBUG_STREAM("Merge result " << mergeTarget);
#endif
}
示例14: jsonValueToVariant
FB::variant jsonValueToVariant( Json::Value root )
{
Json::Value def;
if (root.isString())
return root.asString();
else if (root.isBool())
return root.asBool();
else if (root.isDouble())
return root.asDouble();
else if (root.isInt())
return root.asInt();
else if (root.isUInt())
return root.asUInt();
else if (root.isNull())
return FB::FBNull();
else if (root.isArray()) {
FB::VariantList outList;
for (size_t i = 0; i < root.size(); ++i) {
outList.push_back(jsonValueToVariant(root.get(i, def)));
}
return outList;
} else if (root.isObject()) {
Json::Value::Members members = root.getMemberNames();
FB::VariantMap outMap;
for (Json::Value::Members::iterator it = members.begin(); it != members.end(); ++it)
{
outMap[*it] = jsonValueToVariant(root.get(*it, def));
}
return outMap;
} else {
return FB::FBVoid();
}
}
示例15: diplayRemotes
/* ---------------------------------------------------------------- */
void diplayRemotes()
{
Value::Members members = jsonRoot.getMemberNames();
for (std::vector<string>::iterator it = members.begin(); it != members.end(); ++it)
if (string::npos != (*it).find("remote_"))
cout << " " << *it << endl;
}