本文整理汇总了C++中json::Value::asInt方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::asInt方法的具体用法?C++ Value::asInt怎么用?C++ Value::asInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类json::Value
的用法示例。
在下文中一共展示了Value::asInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: interpolateFrame
void AnimationBuilder::interpolateFrame(ParamsFile &pnew, int frameno)
{
for(auto itP = A.begin(); itP != A.end(); itP ++){
if((*itP).second.lastSetIndex >= (*itP).second.F.size() - 1){
continue;
}
int nextFrameIndex = (*itP).second.lastSetIndex + 1;
KeyFrame nextFrame = (*itP).second.F[nextFrameIndex];
if(nextFrame.frameno == frameno){
*((*itP).second.jsonPtr) = nextFrame.val;
(*itP).second.lastSetIndex = nextFrameIndex;
}else if(nextFrame.interp != "none"){
int fi = (*itP).second.F[(*itP).second.lastSetIndex].frameno;
int ff = nextFrame.frameno;
Json::Value i = (*itP).second.F[(*itP).second.lastSetIndex].val;
Json::Value f = nextFrame.val;
if((*itP).second.pType == SVT_INT){
*((*itP).second.jsonPtr) =
animationInterpolate(nextFrame.interp, frameno, fi, ff, i.asInt(), f.asInt());
}else if((*itP).second.pType == SVT_REAL){
*((*itP).second.jsonPtr) =
animationInterpolate(nextFrame.interp, frameno, fi, ff, i.asDouble(), f.asDouble());
}else if((*itP).second.pType == SVT_COLOR){
Json::Value arr = Json::Value(Json::ValueType::arrayValue);
arr.resize(3);
arr[0] = animationInterpolate(nextFrame.interp, frameno, fi, ff,
i[0].asDouble(), f[0].asDouble());
arr[1] = animationInterpolate(nextFrame.interp, frameno, fi, ff,
i[1].asInt(), f[1].asInt());
arr[2] = animationInterpolate(nextFrame.interp, frameno, fi, ff,
i[2].asInt(), f[2].asInt());
*((*itP).second.jsonPtr) = arr;
}else if((*itP).second.pType == SVT_COMPLEX){
std::complex<double> zi = getComplexValueFromString(i.asString());
std::complex<double> zf = getComplexValueFromString(f.asString());
std::complex<double> z = animationInterpolate(nextFrame.interp, frameno, fi, ff, zi, zf);
std::string res = concat("", z.real()) + concat("+", z.imag()) + "i";
*((*itP).second.jsonPtr) = res;
}
}
}
}
示例2: readInt
int readInt(std::string key, int def)
{
Json::Value val = root.get(key, def);
if (val.isInt())
return val.asInt();
else
return def;
}
示例3: decode_from_json_object
void GetBuyedListRequest::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();
}
}
if ( root.isObject() && root.isMember("total") ) {
tmp = root["total"];
if ( !tmp.isNull() )
{
total = tmp.asInt();
}
}
if ( root.isObject() && root.isMember("errMsg") ) {
tmp = root["errMsg"];
if ( !tmp.isNull() )
{
errMsg = tmp.asString();
}
}
}
示例4: Deserialize
bool Deserialize ( const Json::Value& json_val, int& obj_val )
{
if ( json_val.isInt () )
{
obj_val = json_val.asInt ();
return true;
}
return false;
}
示例5: getUserID
int Response::getUserID() const {
try {
Json::Value json = root["result"][0U]["value"];
return json.asInt();
} catch (...) {
return ERROR;
}
return ERROR;
}
示例6: init
void JsonTree::init( const string &key, const Json::Value &value, bool setType, NodeType nodeType, ValueType valueType )
{
mKey = key;
mNodeType = nodeType;
mParent = 0;
mValue = "";
mValueType = valueType;
if( ! value.isNull() && ( value.isArray() || value.isObject() ) ) {
if( value.isArray() ) {
mNodeType = NODE_ARRAY;
for ( uint32_t i = 0; i < value.size(); i++ ) {
pushBack( JsonTree( "", value[ i ] ) );
}
}
else if( value.isObject() ) {
mNodeType = NODE_OBJECT;
Json::Value::Members members = value.getMemberNames();
for( Json::Value::Members::const_iterator memberIt = members.begin(); memberIt != members.end(); ++memberIt ) {
string key = *memberIt;
pushBack( JsonTree( key, value[ key ] ) );
}
}
}
else {
if( value.isBool() ) {
mValue = toString( value.asBool() );
if( setType ) {
mValueType = VALUE_BOOL;
}
}
else if ( value.isDouble() ) {
mValue = toString( value.asDouble() );
if ( setType ) {
mValueType = VALUE_DOUBLE;
}
}
else if ( value.isInt() ) {
mValue = toString( value.asInt() );
if ( setType ) {
mValueType = VALUE_INT;
}
}
else if ( value.isString() ) {
mValue = toString( value.asString() );
if ( setType ) {
mValueType = VALUE_STRING;
}
}
else if ( value.isUInt() ) {
mValue = toString( value.asUInt() );
if ( setType ) {
mValueType = VALUE_UINT;
}
}
}
}
示例7: leer_datos_iniciales
void leer_datos_iniciales(int &ancho, int &alto, std::string &ip, int &puerto){
Json::Value datos;
Json::Value aux;
Json::Reader reader;
std::string configuracion = CONFIG;
std::ifstream archivo_datos(configuracion.c_str(), std::ifstream::binary | std::ifstream::in);
reader.parse(archivo_datos, datos, false);
aux = datos.get("ancho", aux);
ancho = aux.asInt();
aux = datos.get("alto", aux);
alto = aux.asInt();
aux = datos.get("ip", aux);
ip = aux.asString();
aux = datos.get("puerto", aux);
puerto = aux.asInt();
}
示例8: getnetworkhashps
int getnetworkhashps(){
string command="getnetworkhashps()";
Json::Value params;
Json::Value result;
//params.append(account);
result=this->sendcommand(command,params);
int hashps=result.asInt();
return hashps;
}
示例9: if
bool QSanProtocol::Utils::tryParse(const Json::Value &arg, double &result) {
if (arg.isDouble())
result = arg.asDouble();
else if (arg.isInt())
result = arg.asInt();
else
return false;
return true;
}
示例10: GetInt32
bool GetInt32(const Json::Value& value, int32_t* out) {
if (value.isNull()) {
return false;
}
if (!value.isInt()) {
return false;
}
*out = value.asInt();
return true;
}
示例11: JSON_Type2Type
bool JSON_Type2Type(const Json::Value &subNode, int &value)
{
if (Json::intValue == subNode.type())
{
value = subNode.asInt();
return true;
}
ASSERT_C(false);
return false;
}
示例12: GetJsonInt
int GetJsonInt(const Json::Value& _jsValue)
{
if ( _jsValue.type() == Json::intValue)
return _jsValue.asInt();
else if (_jsValue.type() == Json::stringValue)
return atoi(_jsValue.asCString());
else if (_jsValue.isBool())
return (int)_jsValue.asBool();
return 0;
}
示例13: GetIntFromJsonValue
int Utils::GetIntFromJsonValue(Json::Value &value, int defaultValue) {
int res = defaultValue;
// some json responses have ints formated as strings
if (value.isString())
res = StringToInt(value.asString());
else if (value.isInt())
res = value.asInt();
return res;
}
示例14: switch
static void
printValueTree( FILE *fout, Json::Value &value, const std::string &path = "." )
{
switch ( value.type() )
{
case Json::nullValue:
fprintf( fout, "%s=null\n", path.c_str() );
break;
case Json::intValue:
fprintf( fout, "%s=%ld\n", path.c_str(), value.asInt() );
break;
case Json::uintValue:
fprintf( fout, "%s=%lu\n", path.c_str(), value.asUInt() );
break;
case Json::realValue:
fprintf( fout, "%s=%.16g\n", path.c_str(), value.asDouble() );
break;
case Json::stringValue:
fprintf( fout, "%s=\"%s\"\n", path.c_str(), value.asString().c_str() );
break;
case Json::booleanValue:
fprintf( fout, "%s=%s\n", path.c_str(), value.asBool() ? "true" : "false" );
break;
case Json::arrayValue:
{
fprintf( fout, "%s=[]\n", path.c_str() );
int size = value.size();
for ( int index =0; index < size; ++index )
{
static char buffer[16];
sprintf( buffer, "[%d]", index );
printValueTree( fout, value[index], path + buffer );
}
}
break;
case Json::objectValue:
{
fprintf( fout, "%s={}\n", path.c_str() );
Json::Value::Members members( value.getMemberNames() );
std::sort( members.begin(), members.end() );
std::string suffix = *(path.end()-1) == '.' ? "" : ".";
for ( Json::Value::Members::iterator it = members.begin();
it != members.end();
++it )
{
const std::string &name = *it;
printValueTree( fout, value[name], path + suffix + name );
}
}
break;
default:
break;
}
}
示例15: getParamVal
int getParamVal(std::string param, Json::Value const& item, int defvalue) {
Json::Value nnType = item[param];
if (!nnType.empty())
{
int n = nnType.asInt();
console->info("{0}={1}", param, n);
return n;
}
else
return defvalue;
}