void BuyedListItem::decode_from_json_object(const Json::Value &root) { Json::Value tmp; if ( root.isObject() && root.isMember("contentUuid") ) { tmp = root["contentUuid"]; if ( !tmp.isNull() ) { contentUuid = tmp.asString(); } } if ( root.isObject() && root.isMember("createTime") ) { tmp = root["createTime"]; if ( !tmp.isNull() ) { createTime = tmp.asString(); } } }
void BuyCountItem::decode_from_json_object(const Json::Value &root) { Json::Value tmp; if ( root.isObject() && root.isMember("name") ) { tmp = root["name"]; if ( !tmp.isNull() ) { name = tmp.asString(); } } if ( root.isObject() && root.isMember("count") ) { tmp = root["count"]; if ( !tmp.isNull() ) { count = tmp.asInt(); } } }
void CheckUserNameRequest::decode_from_json_object(const Json::Value &root) { Json::Value tmp; if ( root.isObject() && root.isMember("question") ) { tmp = root["question"]; if ( !tmp.isNull() ) { question.decode_from_json_object(tmp); } } if ( root.isObject() && root.isMember("errMsg") ) { tmp = root["errMsg"]; if ( !tmp.isNull() ) { errMsg = tmp.asString(); } } if ( root.isObject() && root.isMember("status") ) { tmp = root["status"]; if ( !tmp.isNull() ) { status = tmp.asInt(); } } }
void RechargeRequest::decode_from_json_object(const Json::Value &root) { Json::Value tmp; if ( root.isObject() && root.isMember("data") ) { tmp = root["data"]; if ( !tmp.isNull() ) { data.decode_from_json_object(tmp); } } if ( root.isObject() && root.isMember("errMsg") ) { tmp = root["errMsg"]; if ( !tmp.isNull() ) { errMsg = tmp.asString(); } } if ( root.isObject() && root.isMember("status") ) { tmp = root["status"]; if ( !tmp.isNull() ) { status = tmp.asInt(); } } }
void ChangePwdRequest::decode_from_json_object(const Json::Value &root) { Json::Value tmp; if ( root.isObject() && root.isMember("status") ) { tmp = root["status"]; if ( !tmp.isNull() ) { status = tmp.asInt(); } } if ( root.isObject() && root.isMember("msg") ) { tmp = root["msg"]; if ( !tmp.isNull() ) { msg = tmp.asString(); } } }
void CheckUserNameRequestQuestion::decode_from_json_object(const Json::Value &root) { Json::Value tmp; if ( root.isObject() && root.isMember("id") ) { tmp = root["id"]; if ( !tmp.isNull() ) { id = tmp.asString(); } } if ( root.isObject() && root.isMember("name") ) { tmp = root["name"]; if ( !tmp.isNull() ) { name = tmp.asString(); } } }
void GetUserInfoRequest::decode_from_json_object(const Json::Value &root) { Json::Value tmp; if ( root.isObject() && root.isMember("data") ) { tmp = root["data"]; if ( !tmp.isNull() ) { data.decode_from_json_object(tmp); } } if ( root.isObject() && root.isMember("status") ) { tmp = root["status"]; if ( !tmp.isNull() ) { status = tmp.asInt(); } } }
void TemplateParameters::readReweightingParameters(const Json::Value& reweighting, PostProcessing& postproc) /*****************************************************************/ { vector<unsigned int> axes; const Json::Value ax = reweighting["axes"]; if(!ax.isNull()) { for(unsigned int index = 0; index < ax.size(); ++index) { unsigned int axis = ax[index].asUInt(); axes.push_back(axis); } } vector< vector<double> > binss; const Json::Value binnings = reweighting["rebinning"]; if(!binnings.isNull()) { for(unsigned int index = 0; index < binnings.size(); ++index) { vector< double > bins; const Json::Value binning = binnings[index]; for(unsigned int b = 0; b < binning.size(); ++b) { double boundary = binning[b].asDouble(); bins.push_back(boundary); } binss.push_back(bins); } } postproc.addParameter("axes", axes); postproc.addParameter("rebinning", binss); }
void mesos::add_labels(std::shared_ptr<mesos_task> task, const Json::Value& t_val) { Json::Value labels = t_val["labels"]; if(!labels.isNull()) { for(const auto& label : labels) { std::string key, val; Json::Value lkey = label["key"]; Json::Value lval = label["value"]; if(!lkey.isNull()) { key = lkey.asString(); } if(!lval.isNull()) { val = lval.asString(); } std::ostringstream os; os << "Adding Mesos task label: [" << key << ':' << val << ']'; g_logger.log(os.str(), sinsp_logger::SEV_DEBUG); task->emplace_label(mesos_pair_t(key, val)); } } }
std::vector<std::string> k8s_component::extract_nodes_addresses(const Json::Value& status) { std::vector<std::string> address_list; if(!status.isNull()) { Json::Value addresses = status["addresses"]; if(!addresses.isNull() && addresses.isArray()) { for (auto& address : addresses) { if(address.isObject()) { Json::Value::Members addr_names_list = address.getMemberNames(); for (auto& entry : addr_names_list) { if(entry == "address") { Json::Value ip = address[entry]; if(!ip.isNull()) { address_list.emplace_back(std::move(ip.asString())); } } } } } } } return address_list; }
void QimiUserModel::initData(Json::Value data) { if (!data.isNull()) { m_uId = "0"; CC_GAME_JSON_ADD(data, isString, m_sessionKey, "session_key", asString); Json::Value UserData = data["user"]; if (!UserData.isNull()) { CC_GAME_JSON_ADD(UserData, isString, m_uId, "uid", asString); CC_GAME_JSON_ADD(UserData, isString, m_userName, "name", asString); CC_GAME_JSON_ADD(UserData, isString, m_avatarURL, "avatar", asString); CC_GAME_JSON_ADD(UserData, isInt, m_sex, "sex", asInt); CC_GAME_JSON_ADD(UserData, isString, m_email, "email", asString); CC_GAME_JSON_ADD(UserData, isString, m_sessionKey, "session_key", asString); CC_GAME_JSON_ADD(UserData, isInt, m_level, "level", asInt); CC_GAME_JSON_ADD(UserData, isInt, m_score, "score", asInt); CC_GAME_JSON_ADD(UserData, isInt, m_vipLevel, "vip_level", asInt); CC_GAME_JSON_ADD(UserData, isInt, m_vipPrivilege, "vip_privilege", asInt); CC_GAME_JSON_ADD(UserData, isInt, m_birthday, "birthday", asInt); CC_GAME_JSON_ADD(UserData, isInt, m_regdata, "regdata", asInt); CC_GAME_JSON_ADD(UserData, isInt, m_experience, "experience", asInt); } } }
k8s_node_t::host_ip_list k8s_node_t::extract_addresses(const Json::Value& status) { host_ip_list address_list; if(!status.isNull()) { Json::Value addresses = status["addresses"]; if(!addresses.isNull() && addresses.isArray()) { for (auto& address : addresses) { if(address.isObject()) { Json::Value::Members addr_names_list = address.getMemberNames(); for (auto& entry : addr_names_list) { if(entry == "address") { const Json::Value& ip = address[entry]; if(!ip.isNull()) { address_list.emplace(ip.asString()); } } } } } } } return address_list; }
void EvaluatePrequential::doSetParams() { mDataSource = getParam("DataSource", ""); Json::Value jv = getParam("Learner"); if (! jv.isNull()) { mLearnerName = jv["Name"].asString(); mLearnerParams = jv.toStyledString(); } jv = getParam("Evaluator"); if (! jv.isNull()) { mEvaluatorName = jv["Name"].asString(); mEvaluatorParams = jv.toStyledString(); } else { mEvaluatorName = "BasicClassificationEvaluator"; } mReaderName = getParam("Reader", ""); if (mReaderName == "") { jv = getParam("Reader"); if (! jv.isNull()) { mReaderName = jv["Name"].asString(); mReaderParams = jv.toStyledString(); } } }
Expectations::Expectations(Json::Value jsonElement) { if (jsonElement.empty()) { fIgnoreFailure = kDefaultIgnoreFailure; } else { Json::Value ignoreFailure = jsonElement[kJsonKey_ExpectedResults_IgnoreFailure]; if (ignoreFailure.isNull()) { fIgnoreFailure = kDefaultIgnoreFailure; } else if (!ignoreFailure.isBool()) { SkDebugf("found non-boolean json value for key '%s' in element '%s'\n", kJsonKey_ExpectedResults_IgnoreFailure, jsonElement.toStyledString().c_str()); DEBUGFAIL_SEE_STDERR; fIgnoreFailure = kDefaultIgnoreFailure; } else { fIgnoreFailure = ignoreFailure.asBool(); } Json::Value allowedDigests = jsonElement[kJsonKey_ExpectedResults_AllowedDigests]; if (allowedDigests.isNull()) { // ok, we'll just assume there aren't any AllowedDigests to compare against } else if (!allowedDigests.isArray()) { SkDebugf("found non-array json value for key '%s' in element '%s'\n", kJsonKey_ExpectedResults_AllowedDigests, jsonElement.toStyledString().c_str()); DEBUGFAIL_SEE_STDERR; } else { for (Json::ArrayIndex i=0; i<allowedDigests.size(); i++) { fAllowedResultDigests.push_back(GmResultDigest(allowedDigests[i])); } } } }
TEST(jsoncpp, path_list) { std::stringstream ss; ss << getExampleJson(); Json::Value root; Json::Reader reader; //printf("parse, \n%s\n", ss.str().c_str()); bool parsingSuccessful = reader.parse(ss, root); if(!parsingSuccessful) { printf("Failed to parse, %s\n", reader.getFormatedErrorMessages().c_str()); } ASSERT_EQ(parsingSuccessful, true); Json::Path p("plug-ins"); Json::Value v = p.resolve(root); ASSERT_EQ(v.size(), 3); Json::Path p2("plug-ins_xx"); v = p2.resolve(root); ASSERT_EQ(true, v.isNull()); Json::Path p3("plug-ins_xx"); v = p3.resolve(root, "[]"); ASSERT_FALSE(v.isNull()); ASSERT_EQ(0, v.size()); }
void mesos::add_tasks_impl(mesos_framework& framework, const Json::Value& tasks) { if(!tasks.isNull()) { for(const auto& task : tasks) { std::string name, uid, sid; Json::Value fname = task["name"]; if(!fname.isNull()) { name = fname.asString(); } Json::Value fid = task["id"]; if(!fid.isNull()) { uid = fid.asString(); } Json::Value fsid = task["slave_id"]; if(!fsid.isNull()) { sid = fsid.asString(); } std::ostringstream os; os << "Adding Mesos task: [" << framework.get_name() << ':' << name << ',' << uid << ']'; g_logger.log(os.str(), sinsp_logger::SEV_DEBUG); std::shared_ptr<mesos_task> t(new mesos_task(name, uid)); t->set_slave_id(sid); add_labels(t, task); m_state.add_or_replace_task(framework, t); } } else { g_logger.log("tasks is null", sinsp_logger::SEV_DEBUG); } }
void mtsIntuitiveResearchKitECM::Configure(const std::string & filename) { try { std::ifstream jsonStream; Json::Value jsonConfig; Json::Reader jsonReader; jsonStream.open(filename.c_str()); if (!jsonReader.parse(jsonStream, jsonConfig)) { CMN_LOG_CLASS_INIT_ERROR << "Configure " << this->GetName() << ": failed to parse configuration\n" << jsonReader.getFormattedErrorMessages(); return; } ConfigureDH(jsonConfig); // should arm go to zero position when homing, default set in Init method const Json::Value jsonHomingGoesToZero = jsonConfig["homing-zero-position"]; if (!jsonHomingGoesToZero.isNull()) { HomingGoesToZero = jsonHomingGoesToZero.asBool(); } // load tool tip transform if any (for up/down endoscopes) const Json::Value jsonToolTip = jsonConfig["tooltip-offset"]; if (!jsonToolTip.isNull()) { cmnDataJSON<vctFrm4x4>::DeSerializeText(ToolOffsetTransformation, jsonToolTip); ToolOffset = new robManipulator(ToolOffsetTransformation); Manipulator.Attach(ToolOffset); } } catch (...) { CMN_LOG_CLASS_INIT_ERROR << "Configure " << this->GetName() << ": make sure the file \"" << filename << "\" is in JSON format" << std::endl; } }
TEST(jsoncpp, path_parse) { std::stringstream ss; ss << getExampleJson(); Json::Value root; Json::Reader reader; //printf("parse, \n%s\n", ss.str().c_str()); bool parsingSuccessful = reader.parse(ss, root); if(!parsingSuccessful) { printf("Failed to parse, %s\n", reader.getFormatedErrorMessages().c_str()); } ASSERT_EQ(parsingSuccessful, true); Json::Path p("indent.length"); Json::Value v = p.resolve(root); ASSERT_EQ(v.asInt(), 3); Json::Path p2("indent.length_xx"); v = p2.resolve(root); EXPECT_EQ(true, v.isNull()); Json::Path p3("indent.length_xx.yy"); v = p3.resolve(root); EXPECT_EQ(true, v.isNull()); }
Config::Config(const char* configpath) { // DEFAULT CONFIG m_queue_path = "mqueue"; m_queue_name = "mqueue"; m_log_level = mylog :: ROUTN; m_log_name = PROJNAME; m_pollsize = 128; m_wtimeout_ms = 1000; m_rtimeout_ms = 1000; m_ci_port = 1983; m_service_thread_num = 20; m_thread_buffer_size = 10*1024*1024; // ip set // m_cur_no = 0; // 默认关闭IP控制 m_need_ip_control = false; snprintf(m_ip_file, sizeof(m_ip_file), "%s", "./conf/ip_list"); // CUSTOMIZE CONFIG Json::Value root; Json::Reader reader; ifstream in(configpath); if (! reader.parse(in, root)) { FATAL("json format error. USING DEFAULT CONFIG."); MyThrowAssert(0); } Json::Value logConfig = root["LOG"]; if (! logConfig.isNull()) { m_log_level = logConfig[m_StrLogLevel].isNull() ? m_log_level : logConfig[m_StrLogLevel].asInt(); m_log_name = logConfig[m_StrLogName].isNull() ? m_log_name : logConfig[m_StrLogName].asCString(); } SETLOG(m_log_level, m_log_name); Json::Value qSrvConfig = root["CI_SERVER"]; if (! qSrvConfig.isNull()) { m_pollsize = qSrvConfig[m_StrEpollSize].isNull() ? m_pollsize : qSrvConfig[m_StrEpollSize].asInt(); m_wtimeout_ms = qSrvConfig[m_StrQuerySendTimeOut].isNull() ? m_wtimeout_ms : qSrvConfig[m_StrQuerySendTimeOut].asInt(); m_rtimeout_ms = qSrvConfig[m_StrQueryRecvTimeOut].isNull() ? m_rtimeout_ms : qSrvConfig[m_StrQueryRecvTimeOut].asInt(); m_ci_port = qSrvConfig[m_StrCiPort].isNull() ? m_ci_port : qSrvConfig[m_StrCiPort].asInt(); m_service_thread_num = qSrvConfig[m_StrServiceThreadNum].isNull() ? m_service_thread_num : qSrvConfig[m_StrServiceThreadNum].asInt(); m_thread_buffer_size = qSrvConfig[m_StrThreadBufferSize].isNull() ? m_thread_buffer_size : qSrvConfig[m_StrThreadBufferSize].asInt(); uint32_t tint = qSrvConfig[m_StrNeedIpControl].isNull() ? 0 : qSrvConfig[m_StrNeedIpControl].asInt(); m_need_ip_control = (tint != 0); } Json::Value qQueueConfig = root["QUEUE"]; if (! qQueueConfig.isNull()) { m_queue_path = qQueueConfig[m_StrQueuePath].isNull() ? m_queue_path : qQueueConfig[m_StrQueuePath].asCString(); m_queue_name = qQueueConfig[m_StrQueueName].isNull() ? m_queue_name : qQueueConfig[m_StrQueueName].asCString(); } m_queue = new filelinkblock(m_queue_path, m_queue_name, false); }
void ClientWS::processMessage(JSON::Value v) { try { JSON::Value result = v["result"]; JSON::Value error = v["error"]; JSON::Value context = v["context"]; JSON::Value method = v["method"]; JSON::Value id = v["id"]; JSON::Value params = v["params"]; if (result != null || error != null) { if (id != null && !id->isNull()) { natural reqid = id->getUInt(); const Promise<Result> *p = waitingResults.find(reqid); if (p == 0) onDispatchError(v); else { Promise<Result> q = *p; waitingResults.erase(reqid); if (p) { if (error == null || error->isNull()) { q.resolve(Result(result,context)); } else { q.reject(RpcError(THISLOCATION,error)); } } } }//id=null - invalid frame else { onDispatchError(v); } } else if (method != null && params != null) { if (id == null || id->isNull()) { onNotify(method->getStringUtf8(), params, context); } else { try { onIncomeRPC(method->getStringUtf8(), params,context,id); } catch (const RpcError &e) { sendResponse(id, jsonFactory->newValue(null), e.getError()); } catch (const jsonsrv::RpcCallError &c) { RpcError e(THISLOCATION,jsonFactory,c.getStatus(),c.getStatusMessage()); sendResponse(id, jsonFactory->newValue(null), e.getError()); } catch (const std::exception &s) { RpcError e(THISLOCATION,jsonFactory,500,s.what()); sendResponse(id, jsonFactory->newValue(null), e.getError()); } catch (...) { RpcError e(THISLOCATION,jsonFactory,500,"fatal"); sendResponse(id, jsonFactory->newValue(null), e.getError()); } } } } catch (...) { onDispatchError(v); } }
void Channel::ReadConfigJson() { if(g_StaticConfigJson.isNull()) g_StaticConfigJson = ReadSpecifyJson("staticConfigDB.json"); if(g_StaticResultJson.isNull()) g_StaticResultJson = ReadSpecifyJson("staticResult.json"); if(g_VehicleInfoJson.isNull()) g_VehicleInfoJson = ReadSpecifyJson("VehicleInfo.json"); }
bool Json::JsonHandler::readDataJson ( std::string inputFileName ){ std::cout<<"FUNCTION:"<<__FUNCTION__<<'\n'; queryPacketJson packetQuery ; bool parsingSuccessful; try{ fileHandler.open ( inputFileName.c_str() ); if( !fileHandler.is_open() ){ std::cerr<<__FUNCTION__<<"cabt open file for JSON persing\n"; return false; } Json::Value root; Json::Reader reader; if ( !reader.parse( fileHandler , root ) ){ std::cerr<<__FUNCTION__<<"failed to parse JSON file\n"; return false; } Json::Value nodeValue = root ["Query"]; if ( not nodeValue.isNull() ){ std::cout<<__FUNCTION__<<"Json persing Read data= "<< nodeValue.asString()<<'\n'; packetQuery.query =nodeValue.asString(); } else { std::cerr<<__FUNCTION__<<"cant read JSON persing value Query\n"; exit ( -1 ); } nodeValue = root ["Rowcount"]; int rowCount = 0; if ( not nodeValue.isNull() ){ std::cout<<__FUNCTION__<<"Json persing read data for Rowcount=" <<nodeValue.asInt()<<'\n'; rowCount = nodeValue.asInt(); colByColDataTogether.totalRow = rowCount; } else{ std::cerr<<__FUNCTION__<<"cant read Json for Rowcount\n"; } for ( int i = 1 ; i<=rowCount ; i++){ nodeValue = root ["Row"] [static_cast<std::ostringstream*>( &(std::ostringstream() << i) )->str()]; if ( not nodeValue.isNull() ){ std::cout<<__FUNCTION__<<"Json persing for read data [ Row] [ "<<i<< " ] "<<nodeValue.asString()<<std::endl; packetQuery.colInfo.insert ( std::make_pair ( i ,nodeValue.asString() ) ); } else{ std::cerr<<__FUNCTION__<<"Json read error for [ Row ]["<<i <<" ]\n"; exit ( 1 ); } } } catch ( std::exception &e ){ std::cerr<<__FUNCTION__<<"exception cgt at Json Read "<<e.what()<<std::endl; return false; } QueryPacket = packetQuery; return true; }
void deltaTimeInfo::setDelta(const Json::Value& params) { uint32_t samples = 1; uint32_t seconds = 0; uint32_t fraction = 0; uint32_t subFraction = 0; Json::Value value; value = params["samples"]; if(value.isNull()==false) { samples = value.asUInt(); if(samples==0) { throw std::runtime_error("samples must be > 0"); } } const Json::Value& timeObject = params["delta"]; if(timeObject["type"]=="ntp") { value = timeObject["seconds"]; if(value.isNull()==false) { seconds = value.asUInt(); } value = timeObject["fraction"]; if(value.isNull()==false) { fraction = value.asUInt(); } value = timeObject["subFraction"]; if(value.isNull()==false) { subFraction = value.asUInt(); } } uint64_t ntpTimestamp = seconds; ntpTimestamp <<= 32; ntpTimestamp |= fraction; // we are loosing precision here. In order to compensate this, we calculate a correction to use. m_deltaNtpTimestamp = ntpTimestamp/samples; m_deltaSubFraction = subFraction/samples; // determine remainder and calculate sub fraction from it. uint64_t rest = m_deltaNtpTimestamp%samples; rest <<= 32; rest /= samples; m_deltaSubFraction += static_cast < uint32_t > (rest & 0xffffffff); std::cout << __FUNCTION__ << std::endl; std::cout << "seconds = " << seconds << std::hex << " (0x" << seconds << ")" << std::endl; std::cout << "fraction = " << fraction << std::hex << " (0x" << fraction << ")" << std::endl; std::cout << "subFraction = " << subFraction << std::hex << " (0x" << subFraction << ")" << std::endl; }
std::vector<float> ParserActionParameters::parseVector(Json::Value temp_info){ std::vector<float> vector; if(!temp_info.isNull() && temp_info.isArray()){ Json::Value value; for(int i= 0; i< temp_info.size(); ++i){ value = temp_info.get(i,"UTF-8"); if(!value.isNull() && value.isNumeric()){ vector.push_back(value.asFloat()); } } } return vector; }
bool ShopItemInfoFromServer::parseServerInfo(const Json::Value &serverInfo) { if (serverInfo.isNull()) { return false; } const Json::Value serverSubInfo = serverInfo["server"]; if (serverInfo.isNull()) { return false; } return true; }
// To add to an array, getPath() cannot be empty, for example "myarr." or "myobj.myarr." bool JsonDataDelegate::add(const StructuredDataName& name, const std::string& value) { if (name.getPath().empty()) { json_[name.getName()] = value; } else { #if 1 Json::Value* val = (Json::Value*) getJsonPtr(name, true); if (!val) return false; if (name.getName().empty()) { if (val->isArray()) { Json::Value retval = val->append(value); if (retval.isNull()) { return false; } } else { return false; } } else { (*val)[name.getName()] = value; } #else Json::Value val; if (!getJsonValue(name, val, true)) return false; // container not found, cannot add if (name.getName().empty()) { std::string arrName = name.getPath(false); if (val[arrName].isArray()) { Json::Value retval = val[arrName].append(value); if (retval.isNull()) { return false; } } else { return false; } } else { val[name.getName()] = value; } #endif } return true; }
robManipulator::Errno robManipulator::LoadRobot(const Json::Value &config) { if (config.isNull()) { CMN_LOG_RUN_ERROR << "JSON value is NULL" << std::endl; return robManipulator::EFAILURE; } // get robot name CMN_LOG_RUN_DEBUG << config.get("name", "robot").asString() << std::endl; // get number of links int numLinks = config.get("numOfLinks", -1).asInt(); if (numLinks == -1) { CMN_LOG_RUN_ERROR << "Can't find number of links" << std::endl; return robManipulator::EFAILURE; } // load each link for (int i = 0; i < numLinks; i++) { const Json::Value jlink = config["links"][i]; if (jlink.isNull()) { CMN_LOG_RUN_ERROR << "Can't link " << i+1 << std::endl; return robManipulator::EFAILURE; } // Find the type of kinematics convention std::string convention; convention = jlink.get("convention", "standard").asString(); robKinematics* kinematics = NULL; try{ kinematics = robKinematics::Instantiate( convention ); } catch( std::bad_alloc& ){ CMN_LOG_RUN_ERROR << CMN_LOG_DETAILS << "Failed to allocate a kinematics of type: " << convention << std::endl; } CMN_ASSERT( kinematics != NULL ); robLink li( kinematics, robMass() ); li.Read(jlink); links.push_back(li); } Js = rmatrix(0, links.size()-1, 0, 5); Jn = rmatrix(0, links.size()-1, 0, 5); return robManipulator::ESUCCESS; }
static bool handleNumberOptions(const Json::Value& options, ENumberType& type, std::string& error) { if (options.isNull()) return true; if (!options.isObject()) { slog2f(0, ID_G11N, SLOG2_ERROR, "GlobalizationNDK::handleNumberOptions: invalid options type: %d", options.type()); error = "Invalid options type!"; return false; } Json::Value tv = options["type"]; if (tv.isNull()) { slog2f(0, ID_G11N, SLOG2_ERROR, "GlobalizationNDK::handleNumberOptions: No type found!"); error = "No type found!"; return false; } if (!tv.isString()) { slog2f(0, ID_G11N, SLOG2_ERROR, "GlobalizationNDK::handleNumberOptions: Invalid type type: %d", tv.type()); error = "Invalid type type!"; return false; } std::string tstr = tv.asString(); if (tstr.empty()) { slog2f(0, ID_G11N, SLOG2_ERROR, "GlobalizationNDK::handleNumberOptions: Empty type!"); error = "Empty type!"; return false; } if (tstr == "currency") { type = kNumberCurrency; } else if (tstr == "percent") { type = kNumberPercent; } else if (tstr == "decimal") { type = kNumberDecimal; } else { slog2f(0, ID_G11N, SLOG2_ERROR, "GlobalizationNDK::handleNumberOptions: unsupported type: %s", tstr.c_str()); error = "Unsupported type!"; return false; } return true; }
void CUser::InitUserInfoFromJson(const Json::Value val) { #if 0 if (val.isNull()) { return; } std::string strArray[13] = {"status","temp","id", "nickName","address", "mobile","contractor","shopName","mobileValid","realNameValid","thumb","email","merchant" }; linkmaninfo* pInfo = new linkmaninfo(); m_selfInfo.status = val[strArray[0]].asInt(); m_selfInfo.temp = val[strArray[1]].asString().c_str(); m_selfInfo.id = val[strArray[2]].asString().c_str(); m_selfInfo.nickname = val[strArray[3]].asString().c_str(); m_selfInfo.address = val[strArray[4]].asString().c_str(); m_selfInfo.mobile = val[strArray[5]].asString().c_str(); m_selfInfo.contractor = val[strArray[6]].asString().c_str(); m_selfInfo.shopname = val[strArray[7]].asString().c_str(); m_selfInfo.mobilevalid = val[strArray[8]].asBool(); m_selfInfo.realnamevalid = val[strArray[9]].asBool(); m_selfInfo.thumb = val[strArray[10]].asString().c_str(); m_selfInfo.email = val[strArray[11]].asString().c_str(); m_selfInfo.merchant = val[strArray[12]].asBool(); #endif if (!m_pConnResponse) m_pConnResponse = new ConnectResponse; m_pConnResponse->FromJson(val); }
void JsonRpcPrivate::jsonReaderCallback(std::string const & jsonText) { Json::Value request; Json::Value response; Json::Reader reader; bool const success(reader.parse(jsonText, request)); if (!success) { response = parseError(); } else if (request.isObject()) { response = handleObject(request); } else if (request.isArray()) { response = handleArray(request); } else { Json::Value const null; response = invalidRequest(null); } if (!response.isNull()) { try { serializeAndSendJson(response, m_output); } catch (const std::exception &e) { // NOLINT fprintf( stderr, "exception sending response: %s\n", e.what()); } } }