本文整理汇总了C++中json::Value::isConvertibleTo方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::isConvertibleTo方法的具体用法?C++ Value::isConvertibleTo怎么用?C++ Value::isConvertibleTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类json::Value
的用法示例。
在下文中一共展示了Value::isConvertibleTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ke
void
injectRefs (Json::Value ¶ms, Json::Value &responses)
{
if (params.isObject () || params.isArray () ) {
for (auto it = params.begin(); it != params.end() ; it++) {
injectRefs (*it, responses);
}
} else if (params.isConvertibleTo (Json::ValueType::stringValue) ) {
std::string param = JsonFixes::getString (params);
if (param.size() > NEW_REF.size()
&& param.substr (0, NEW_REF.size() ) == NEW_REF) {
std::string ref = param.substr (NEW_REF.size() );
try {
int index = stoi (ref);
insertResult (params, responses, index);
} catch (std::invalid_argument &e) {
Json::Value data;
KurentoException ke (MALFORMED_TRANSACTION,
"Invalid index of newref '" + ref + "'");
data[TYPE] = ke.getType();
throw JsonRpc::CallException (ke.getCode (), ke.getMessage (), data);
}
}
}
}
示例2:
Temperatures::Temperatures(const Json::Value& reply) :
beerReading(compact_or_verbose(reply, "bt", "BeerTemp").asDouble()),
beerSetting(compact_or_verbose(reply, "bs", "BeerSet").asDouble()),
beerAnnotation(compact_or_verbose(reply, "ba", "BeerAnn").asString()),
fridgeReading(compact_or_verbose(reply, "ft", "FridgeTemp").asDouble()),
fridgeSetting(compact_or_verbose(reply, "fs", "FridgeSet").asDouble()),
fridgeAnnotation(compact_or_verbose(reply, "fa", "FridgeAnn").asString()),
roomTemp(compact_or_verbose(reply, "rt", "RoomTemp").asDouble()),
state(Temperatures::State::Null) {
const Json::Value state_value = compact_or_verbose(reply, "s", "State");
if(!state_value.isNull() && state_value.isConvertibleTo(Json::intValue)) {
int state_int = state_value.asInt();
if(state_int < 0 || state_int >= static_cast<int>(Temperatures::State::MAX_VALUE)) {
state = Temperatures::State::Null;
} else {
state = static_cast<State>(state_int);
}
}
}
示例3: if
bool k8s_api_handler::handle_component(const Json::Value& json, const msg_data* data)
{
m_error = false;
if(!json.isNull())
{
if(json.isArray())
{
for(const auto& version : json)
{
if(version.isConvertibleTo(Json::stringValue))
{
m_extensions.push_back(version.asString());
}
else
{
g_logger.log("K8s API handler error: could not extract API versions or extensions from JSON.",
sinsp_logger::SEV_ERROR);
m_error = true;
return false;
}
}
}
else if(json.isConvertibleTo(Json::stringValue))
{
m_extensions.push_back(json.asString());
}
else
{
g_logger.log("K8s API handler error: could not extract API versions or extensions from JSON.",
sinsp_logger::SEV_ERROR);
m_error = true;
return false;
}
m_data_received = true;
}
else
{
g_logger.log("K8s API handler error: json is null.", sinsp_logger::SEV_ERROR);
m_error = true;
return false;
}
return true;
}
示例4: _Deserialize
void _Deserialize(const AuthorizedObject &parent_obj, const Json::Value &json)
{
if(!json.isConvertibleTo(Json::stringValue))
throw UnexpectedException("!json.isConvertibleTo(Json::stringValue)");
const std::string &str = json.asString();
bool found = false;
// Hack: This is nasty, but required to do a complete iteration. Hopefully, we never have to go over the int limit!
for(int s = (int)none; s < (int)count; ++s)
{
if(stricmp(str.c_str(), str_array[s]) == 0)
{
t_ = (T)s;
break;
}
}
if(!found)
throw UnexpectedException("!found");
}