Example #1
0
bool GetBool( Json::Value const &V, bool& O)
{
    if ( !V.isBool() )
    {
        return false;
    }
    O = V.asBool();
    return true;
}
Example #2
0
bool BlockChain::isSyncing()
{
    Json::Value result = _provider.request("eth_isSyncing");
    if(result.isBool())
    {
        return result.asBool();
    }
    return true;
}
Example #3
0
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;
			}
		}
	}
}
Example #4
0
bool GetBool(const Json::Value& value, bool* out) {
  if (value.isNull()) {
    return false;
  }
  if (!value.isBool()) {
    return false;
  }
  *out = value.asBool();
  return true;
}
bool ConfigFile::is_data_shared_1(std::string package) {
    const Json::Value sharedata =
            m_root[CONF_PACKAGES][package][CONF_SHARE_DATA];

    if (!sharedata.isNull() && !sharedata.isBool()) {
        return sharedata.asBool();
    }

    return false;
}
Example #6
0
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;
}
Example #7
0
    bool JsonUtils::asBool(const Json::Value &value, bool defaultValue)
    {
        bool returned = defaultValue;

        if(value.isString())
            returned = Ogre::StringConverter::parseBool(value.asString(), defaultValue);

        if(value.isBool())
            returned = value.asBool();

        return returned;
    }
Example #8
0
//------------------------------------------------------------------------------
bool WidgetHints::isEnabled(const std::string &name) const
{
  Json::Value value = this->Internals->findValue(name + "/enabled");

  if (value.isBool())
    {
    return value.asBool();
    }

  // True by default:
  return true;
}
Example #9
0
 void SpriteRenderer::onDeserialize( const std::string& property, const Json::Value& root )
 {
     if( property == "Texture" && root.isString() )
         setTexture( Assets::use().getTexture( root.asString() ) );
     else if( property == "Size" && root.isArray() && root.size() == 2 )
     {
         setSize( sf::Vector2f(
             (float)root[ 0u ].asDouble(),
             (float)root[ 1u ].asDouble()
         ) );
     }
     else if( property == "Origin" && root.isArray() && root.size() == 2 )
     {
         setOrigin( sf::Vector2f(
             (float)root[ 0u ].asDouble(),
             (float)root[ 1u ].asDouble()
         ) );
     }
     else if( property == "OriginPercent" && root.isArray() && root.size() == 2 )
     {
         setOriginPercent( sf::Vector2f(
             (float)root[ 0u ].asDouble(),
             (float)root[ 1u ].asDouble()
         ) );
     }
     else if( property == "Color" && root.isArray() && root.size() == 4 )
     {
         setColor( sf::Color(
             root[ 0u ].asUInt(),
             root[ 1u ].asUInt(),
             root[ 2u ].asUInt(),
             root[ 3u ].asUInt()
         ) );
     }
     else if( property == "RenderStates" && root.isObject() )
     {
         Json::Value blendMode = root[ "blendMode" ];
         if( blendMode.isString() )
             m_renderStates.blendMode = Serialized::deserializeCustom< sf::BlendMode >( "BlendMode", blendMode );
         Json::Value shader = root[ "shader" ];
         if( shader.isString() )
             m_renderStates.shader = Assets::use().getShader( shader.asString() );
     }
     else if( property == "Material" && root.isObject() )
         m_material.deserialize( root );
     else if( property == "MaterialValidation" && root.isBool() )
         m_materialValidation = root.asBool();
     else
         Component::onDeserialize( property, root );
 }
Example #10
0
void 
ValueTest::checkIs( const Json::Value &value, const IsCheck &check )
{
   JSONTEST_ASSERT_EQUAL( check.isObject_, value.isObject() );
   JSONTEST_ASSERT_EQUAL( check.isArray_, value.isArray() );
   JSONTEST_ASSERT_EQUAL( check.isBool_, value.isBool() );
   JSONTEST_ASSERT_EQUAL( check.isDouble_, value.isDouble() );
   JSONTEST_ASSERT_EQUAL( check.isInt_, value.isInt() );
   JSONTEST_ASSERT_EQUAL( check.isUInt_, value.isUInt() );
   JSONTEST_ASSERT_EQUAL( check.isIntegral_, value.isIntegral() );
   JSONTEST_ASSERT_EQUAL( check.isNumeric_, value.isNumeric() );
   JSONTEST_ASSERT_EQUAL( check.isString_, value.isString() );
   JSONTEST_ASSERT_EQUAL( check.isNull_, value.isNull() );
}
Example #11
0
bool deserialize(const Json::Value& node, bool& b)
{
	if (node.empty())
	{
		std::cout << "Node is empty." << std::endl;
		return false;
	}
	if (!node.isBool())
	{
		std::cout << "Node data type is not boolean." << std::endl;
		return false;
	}
	b = node.asBool();
	return true;
}
Example #12
0
void util::PrintJSONValue( Json::Value val ){
	if( val.isString() ) {
		printf( "string(%s)", val.asString().c_str() ); 
	} else if( val.isBool() ) {
		printf( "bool(%d)", val.asBool() ); 
	} else if( val.isInt() ) {
		printf( "int(%d)", val.asInt() ); 
	} else if( val.isUInt() ) {
		printf( "uint(%u)", val.asUInt() ); 
	} else if( val.isDouble() ) {
		printf( "double(%f)", val.asDouble() ); 
	} else {
		printf( "unknown type=[%d]", val.type() ); 
	}
}
Example #13
0
	void Log::execute(fsm::Context * ctx, const log4cplus::Logger & log, const std::string & sessionId)const
	{
		std::string loginfo = m_strExpr;
		if (ctx && m_Type.compare("script") == 0) { 
			Json::Value jsonval = ctx->eval(m_strExpr, m_strFileName, m_lineNo/*,m_node*/);
			if (jsonval.isString() || jsonval.isBool() || jsonval.isNull()){
				loginfo = jsonval.asString();
			}
			else if (jsonval.isInt()){
				loginfo = std::to_string(jsonval.asInt());
			}
			else if (jsonval.isUInt()){
				loginfo = std::to_string(jsonval.asUInt());
			}
			else if (jsonval.isDouble()){
				loginfo = std::to_string(jsonval.asDouble());
			}
			else if (jsonval.isObject())
			{
				loginfo = jsonval.toStyledString();
			}
		}

		if (m_strLevel.compare("trace") == 0){
			LOG4CPLUS_TRACE(log, "." + sessionId,  m_strFileName << ":" << m_lineNo << "," << loginfo);
		}
		else if (m_strLevel.compare("debug") == 0){
			LOG4CPLUS_DEBUG(log, "." + sessionId, m_strFileName << ":" << m_lineNo << "," << loginfo);
		}
		else if (m_strLevel.compare("info") == 0){
			LOG4CPLUS_INFO(log, "." + sessionId, m_strFileName << ":" << m_lineNo << "," << loginfo);
		}
		else if (m_strLevel.compare("warn") == 0){
			LOG4CPLUS_WARN(log, "." + sessionId, m_strFileName << ":" << m_lineNo << "," << loginfo);
		}
		else if (m_strLevel.compare("error") == 0){
			LOG4CPLUS_ERROR(log, "." + sessionId, m_strFileName << ":" << m_lineNo << "," << loginfo);
		}
		else if (m_strLevel.compare("fatal") == 0){
			LOG4CPLUS_FATAL(log, "." + sessionId, m_strFileName << ":" << m_lineNo << "," << loginfo);
		}
		else{

			LOG4CPLUS_INFO(log, "." + sessionId, m_strFileName << ":" << m_lineNo << "," << loginfo);
		}
	}
Example #14
0
bool VehicleInfo::getVehicleData(Json::Value &message,Json::Value &result)
{
    Json::Value vehicle;
    Json::Value data;
    Json::Value params;
    bool ret = false;

    params = message["params"];

    vehicle = g_VehicleInfoJson["vehicle"];

    Json::Value::Members mem = params.getMemberNames();
    for (Json::Value::Members::iterator iter = mem.begin(); iter != mem.end(); iter++) {
        std::string infoitem = std::string(*iter);
        if (infoitem != "appID" && infoitem != "request") {
            Json::Value require = params[infoitem];
            if (!require.isBool())
                continue;
            if (!require.asBool())
                continue;

            if (vehicle.isMember(infoitem))
                data[infoitem] = vehicle[infoitem];
            ret = true;
        }
    }

    if (ret) {
        Json::Value::Members mem = data.getMemberNames();
        for (Json::Value::Members::iterator iter = mem.begin(); iter != mem.end(); iter++) {
            std::string infoitem = std::string(*iter);
            result[infoitem] = data[infoitem];
        }

        result["code"] = 0;
        result["method"] = "VehicleInfo.GetVehicleData";
    } else {
        result["message"] = "Params rpc, are not avaliable";
        result["code"] = 9;
        result["method"]="VehicleInfo.GetVehicleData";
    }

    return ret;
}
Example #15
0
 void LuaModule::pushValue(const Json::Value &val, lua_State * stack) {
     if (val.isIntegral()) {
         lua_pushinteger(stack, val.asInt());
     } else if (val.isDouble()) {
         lua_pushnumber(stack, val.asDouble());
     } else if (val.isBool()) {
         lua_pushboolean(stack, val.asBool());
     } else if (val.isString()) {
         lua_pushstring(stack, val.asString().c_str());
     } else if (val.isNull()) {
         //lua_pushstring(stack, val.asString().c_str());
         lua_pushnil(stack);
     } else {
         lua_pop(stack, 1);
         std::stringstream ss;
         ss << val.type();
         std::string typeNum;
         ss >> typeNum;
         throw std::runtime_error("Value type error: value of type " + typeNum);
     }
 }
bool QSanProtocol::Utils::tryParse(const Json::Value &arg, bool &result) {
    if (!arg.isBool()) return false;
    result = arg.asBool();
    return true;
}
Example #17
0
  void LuaContext::PushJson(const Json::Value& value)
  {
    if (value.isString())
    {
      const std::string s = value.asString();
      lua_pushlstring(lua_, s.c_str(), s.size());
    }
    else if (value.isDouble())
    {
      lua_pushnumber(lua_, value.asDouble());
    }
    else if (value.isInt())
    {
      lua_pushinteger(lua_, value.asInt());
    }
    else if (value.isUInt())
    {
      lua_pushinteger(lua_, value.asUInt());
    }
    else if (value.isBool())
    {
      lua_pushboolean(lua_, value.asBool());
    }
    else if (value.isNull())
    {
      lua_pushnil(lua_);
    }
    else if (value.isArray())
    {
      lua_newtable(lua_);

      // http://lua-users.org/wiki/SimpleLuaApiExample
      for (Json::Value::ArrayIndex i = 0; i < value.size(); i++)
      {
        // Push the table index (note the "+1" because of Lua conventions)
        lua_pushnumber(lua_, i + 1);

        // Push the value of the cell
        PushJson(value[i]);

        // Stores the pair in the table
        lua_rawset(lua_, -3);
      }
    }
    else if (value.isObject())
    {
      lua_newtable(lua_);

      Json::Value::Members members = value.getMemberNames();

      for (Json::Value::Members::const_iterator 
             it = members.begin(); it != members.end(); ++it)
      {
        // Push the index of the cell
        lua_pushlstring(lua_, it->c_str(), it->size());

        // Push the value of the cell
        PushJson(value[*it]);

        // Stores the pair in the table
        lua_rawset(lua_, -3);
      }
    }
    else
    {
      throw OrthancException(ErrorCode_JsonToLuaTable);
    }
  }
Example #18
0
bool markupFormHelper(const char* bvPath, Mat& markupImage, bool drawCounts) {	
	Json::Value bvRoot;
	
	if( !parseJsonFromFile(bvPath, bvRoot) ) return false;
	
	const Json::Value fields = bvRoot["fields"];
	for ( size_t i = 0; i < fields.size(); i++ ) {
		const Json::Value field = fields[i];
		
		//TODO: For multi-choice forms were going to want something a little different.
		//	This function is getting pretty complicated and should probably be split up.
		size_t filledItems = 0;
		float avgWidth = 0;
		float avgY = 0;
		int endOfField = 0;
		
		#ifdef SHOW_MIN_ERROR_CUT
			//Should this be specified in the template??
			int cutIdx = minErrorCut(computedFilledIntegral(field));
			int ItemNum = 0;
		#endif
		
		string fieldName = field.get("label", "Unlabeled").asString();
		Scalar boxColor = getColor(int(i));
	
		const Json::Value segments = field["segments"];
		
		for ( size_t j = 0; j < segments.size(); j++ ) {
			const Json::Value segment = segments[j];

			//TODO: unaligned segments could be an issue

			//Draw segment rectangles:
			vector<Point> quad = orderCorners( jsonArrayToQuad(segment["quad"]) );
			const Point* p = &quad[0];
			int n = (int) quad.size();
			polylines(markupImage, &p, &n, 1, true, boxColor, 2, CV_AA);
			
			if( segment.get("notFound", false).asBool() ) {
				polylines(markupImage, &p, &n, 1, true, .25 * boxColor, 2, CV_AA);
			}
			else{
				polylines(markupImage, &p, &n, 1, true, boxColor, 2, CV_AA);
			}
			
			//Compute some stuff to figure out where to draw output on the form
			avgWidth += norm(quad[0] - quad[1]);
			if(endOfField < quad[1].x){
				endOfField = quad[1].x;
			}
			avgY += quad[3].y;// + quad[1].y + quad[2].y + quad[3].y) / 4;
			

			const Json::Value items = segment["items"];
			for ( size_t k = 0; k < items.size(); k++ ) {
				const Json::Value Item = items[k];
				Point ItemLocation(jsonToPoint(Item["absolute_location"]));
				Json::Value classification = Item["classification"];
				if(classification.isBool()){
					if(classification.asBool()){
						filledItems++;
					}
					circle(markupImage, ItemLocation, 2, 	getColor(classification.asBool()), 1, CV_AA);
				}
				else if(classification.isInt()){
					circle(markupImage, ItemLocation, 2, 	getColor(classification.asInt()), 1, CV_AA);
				}
				else{
					cout << "Don't know what this is" << endl;
				}
				
			}
		}
		if(field.get("type", "input") == "input"){
			//Print the counts on the form:
			if(drawCounts && avgWidth > 0){
				avgWidth /= segments.size();
				avgY /= segments.size();
			
			
				Point textBoxTL(endOfField + 5, (int)avgY - 5);
				if(field.isMember("print_count_location")){
					textBoxTL = jsonToPoint(field["print_count_location"]);
				}
			
				stringstream ss;
				ss << filledItems;
				putText(markupImage, ss.str(), textBoxTL,  FONT_HERSHEY_SIMPLEX, 1., Scalar::all(0), 3, CV_AA);
				putText(markupImage, ss.str(), textBoxTL,  FONT_HERSHEY_SIMPLEX, 1., boxColor, 2, CV_AA);
			}
		}
		
	}
	return true;
}
Example #19
0
	void Deserialize_Boolean( const Json::Value& srcValue, bool &dstValue )
	{
		CHK_VRET_IF_NOT( srcValue.isBool() );
		dstValue = srcValue.asBool();
	}
void ApplyUserAttributes(std::string name, AtNode* node,std::vector<std::string> tags,ProcArgs & args)
{

   bool foundInPath = false;
   for(std::vector<std::string>::iterator it=args.userAttributes.begin(); it!=args.userAttributes.end(); ++it)
   {
      Json::Value userAttributes;                        
      if(it->find("/") != std::string::npos) // Based on path
      {
        if(name.find(*it) != std::string::npos)
        {
          userAttributes = args.userAttributesRoot[*it];
          foundInPath = true;
        }
      } 
      else if(matchPattern(name,*it)) // based on wildcard expression
      {
          userAttributes = args.userAttributesRoot[*it];
          foundInPath = true;
      }
      else if(foundInPath == false)
      {
        if (std::find(tags.begin(), tags.end(), *it) != tags.end())
        {
          userAttributes = args.userAttributesRoot[*it];
        }
      }

      if(userAttributes.size() > 0)
      {
        for( Json::ValueIterator itr = userAttributes.begin() ; itr != userAttributes.end() ; itr++ ) 
        {
            std::string attribute = itr.key().asString();

            if( AiNodeLookUpUserParameter(node,attribute.c_str()))
              continue;

            const AtNodeEntry* nodeEntry = AiNodeGetNodeEntry(node);
            Json::Value val = args.userAttributesRoot[*it][attribute];
            if( val.isString() ) 
            {
              AddUserGeomParams(node,attribute.c_str(),AI_TYPE_STRING);
              AiNodeSetStr(node, attribute.c_str(), val.asCString());
            } 
            else if( val.isBool() ) 
            {
              AddUserGeomParams(node,attribute.c_str(),AI_TYPE_BOOLEAN);
              AiNodeSetBool(node, attribute.c_str(), val.asBool());
            }
            else if( val.isInt() ) 
            {
              AddUserGeomParams(node,attribute.c_str(),AI_TYPE_INT);
              AiNodeSetInt(node, attribute.c_str(), val.asInt());
            }
            else if( val.isUInt() ) 
            {
              AddUserGeomParams(node,attribute.c_str(),AI_TYPE_UINT);
              AiNodeSetUInt(node, attribute.c_str(), val.asUInt());
            }
            else if(val.isDouble())
            {
              AddUserGeomParams(node,attribute.c_str(),AI_TYPE_FLOAT);
              AiNodeSetFlt(node, attribute.c_str(), val.asDouble());
            }
            else if(val.isArray()) 
            {              

              // in the future we will convert to an arnold array type for now lets just 
              // write out a json string

              AddUserGeomParams(node,attribute.c_str(),AI_TYPE_STRING);
              Json::FastWriter writer;
              AiNodeSetStr(node, attribute.c_str(), writer.write(val).c_str());
              
              // AddUserGeomParams(node,attribute.c_str(),AI_TYPE_ARRAY );

              // // get the type of the first entry, this will be our key as to
              // // what type of data is in this array
              // Json::Value firstValue = val[0];
              // if (firstValue.isString())
              // {
              //   AtArray* arrayValues = AiArrayAllocate( val.size() , 1, AI_TYPE_STRING);

              //   for( uint idx = 0 ; idx != val.size() ; idx++ ) 
              //   {
              //     AiMsgInfo("[ABC] adding string %s to user array attribute '%s'",val[idx].asCString(),attribute.c_str());
              //     AiArraySetStr(arrayValues,idx,val[idx].asCString());
              //   }

              //   AiNodeSetArray(node, attribute.c_str(), arrayValues);         
              // }
     
            }

            // TODO color, matrix, vector

         }
      }
   }
}
void ApplyOverrides(std::string name, AtNode* node, std::vector<std::string> tags, ProcArgs & args)
{
   bool foundInPath = false;
   for(std::vector<std::string>::iterator it=args.overrides.begin(); it!=args.overrides.end(); ++it)
   {
      Json::Value overrides;                        
      if(it->find("/") != std::string::npos) // Based on path
      {
        if(name.find(*it) != std::string::npos)
        {
          overrides = args.overrideRoot[*it];
          foundInPath = true;
        }
      } 
      else if(matchPattern(name,*it)) // based on wildcard expression
      {
          overrides = args.overrideRoot[*it];
          foundInPath = true;
      }
      else if(foundInPath == false)
      {
        if (std::find(tags.begin(), tags.end(), *it) != tags.end())
        {
          overrides = args.overrideRoot[*it];
        }
      }

      if(overrides.size() > 0)
      {
        for( Json::ValueIterator itr = overrides.begin() ; itr != overrides.end() ; itr++ ) 
        {
          std::string attribute = itr.key().asString();

          const AtNodeEntry* nodeEntry = AiNodeGetNodeEntry(node);
          const AtParamEntry* paramEntry = AiNodeEntryLookUpParameter(nodeEntry, attribute.c_str());

          if ( paramEntry != NULL && attribute!="invert_normals" || attribute == "matte")
          {

            Json::Value val = args.overrideRoot[*it][itr.key().asString()];
            if( val.isString() ) 
              AiNodeSetStr(node, attribute.c_str(), val.asCString());
            else if( val.isBool() )
            {
              if(attribute == "matte")
              {
                  AiMsgDebug("[ABC] adding enable_matte to %s", AiNodeGetName(node));
                  AddUserGeomParams(node,"enable_matte",AI_TYPE_BOOLEAN);
                  AiNodeSetBool(node,"enable_matte", val.asBool());
              }
              else
              {
                  AiNodeSetBool(node, attribute.c_str(), val.asBool());
              }
            }
            else if( val.isInt() ) 
            {
              //make the difference between Byte & int!
              int typeEntry = AiParamGetType(paramEntry);
              if(typeEntry == AI_TYPE_BYTE)
              { 
                if(attribute=="visibility")
                {
                  AtByte attrViz = val.asInt();
                  // special case, we must determine it against the general viz.
                  AtByte procViz = AiNodeGetByte( args.proceduralNode, "visibility" );
                  AtByte compViz = AI_RAY_ALL;
                  {
                    compViz &= ~AI_RAY_GLOSSY;
                    if(procViz > compViz)
                      procViz &= ~AI_RAY_GLOSSY;
                    else
                      attrViz &= ~AI_RAY_GLOSSY;
                    compViz &= ~AI_RAY_DIFFUSE;
                    if(procViz > compViz)
                      procViz &= ~AI_RAY_DIFFUSE;
                    else
                      attrViz &= ~AI_RAY_DIFFUSE;
                    compViz &= ~AI_RAY_REFRACTED;
                    if(procViz > compViz)
                      procViz &= ~AI_RAY_REFRACTED;
                    else
                      attrViz &= ~AI_RAY_REFRACTED;
                    compViz &= ~AI_RAY_REFLECTED;
                    if(procViz > compViz)
                      procViz &= ~AI_RAY_REFLECTED;
                    else
                      attrViz &= ~AI_RAY_REFLECTED;
                    compViz &= ~AI_RAY_SHADOW;
                    if(procViz > compViz)
                      procViz &= ~AI_RAY_SHADOW;
                    else
                      attrViz &= ~AI_RAY_SHADOW;
                    compViz &= ~AI_RAY_CAMERA;
                    if(procViz > compViz)
                      procViz &= ~AI_RAY_CAMERA;
                    else
                      attrViz &= ~AI_RAY_CAMERA;
                  }

                  AiNodeSetByte(node, attribute.c_str(), attrViz);
                }
                else
                  AiNodeSetByte(node, attribute.c_str(), val.asInt());
              }
              else 
                AiNodeSetInt(node, attribute.c_str(), val.asInt());
            }
            else if( val.isUInt() ) 
              AiNodeSetUInt(node, attribute.c_str(), val.asUInt());
            else if( val.isDouble() ) 
              AiNodeSetFlt(node, attribute.c_str(), val.asDouble());
          }
        }
      }

   }
}
void
TrexRpcCommand::check_field_type_common(const Json::Value &field, const std::string &name, field_type_e type, Json::Value &result) {
    std::stringstream ss;

    /* first check if field exists */
    if (field == Json::Value::null) {
        ss << "field '" << name << "' is missing";
        generate_parse_err(result, ss.str());
    }

    bool rc = true;

    switch (type) {
    case FIELD_TYPE_BYTE:
        if ( (!field.isUInt()) || (field.asInt() > 0xFF)) {
            rc = false;
        }
        break;

    case FIELD_TYPE_UINT16:
        if ( (!field.isUInt()) || (field.asInt() > 0xFFFF)) {
            rc = false;
        }
        break;

    case FIELD_TYPE_UINT32:
        if ( (!field.isUInt()) || (field.asUInt() > 0xFFFFFFFF)) {
            rc = false;
        }
        break;

    case FIELD_TYPE_UINT64:
        if (!field.isUInt64()) {
            rc = false;
        }
        break;

    case FIELD_TYPE_BOOL:
        if (!field.isBool()) {
            rc = false;
        }
        break;

    case FIELD_TYPE_INT:
        if (!field.isInt()) {
            rc = false;
        }
        break;

    case FIELD_TYPE_DOUBLE:
        if (!field.isDouble()) {
            rc = false;
        }
        break;

    case FIELD_TYPE_OBJ:
        if (!field.isObject()) {
            rc = false;
        }
        break;

    case FIELD_TYPE_STR:
        if (!field.isString()) {
            rc = false;
        }
        break;

    case FIELD_TYPE_ARRAY:
        if (!field.isArray()) {
            rc = false;
        }
        break;

    default:
        throw TrexRpcException("unhandled type");
        break;

    }
    if (!rc) {
        ss << "error at offset: " << field.getOffsetStart() << " - '" << name << "' is '" << json_type_to_name(field) << "', expecting '" << type_to_str(type) << "'";
        generate_parse_err(result, ss.str());
    }

}