本文整理汇总了C++中json::Value::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::isNull方法的具体用法?C++ Value::isNull怎么用?C++ Value::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类json::Value
的用法示例。
在下文中一共展示了Value::isNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: decode_from_json_object
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();
}
}
}
示例2: readReweightingParameters
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);
}
示例3: add_labels
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));
}
}
}
示例4:
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;
}
示例5: initData
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);
}
}
}
示例6:
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;
}
示例7: doSetParams
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();
}
}
}
示例8: if
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]));
}
}
}
}
示例9: p
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());
}
示例10: add_tasks_impl
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);
}
}
示例11: in
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);
}
示例12: processMessage
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);
}
}
示例13: ReadConfigJson
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");
}
示例14:
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;
}
示例15: setDelta
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;
}