Beispiel #1
0
void DirectHandler::handleData(const JSONEntity& val)
{
	if (isArray())
	{
		switch(val.type())
		{
		case JSONEntity::JSON_T_STRING:
			_data.push_back(val.toString());
			break;
		case JSONEntity::JSON_T_INTEGER:
			_data.push_back(val.toInteger());
			break;
		case JSONEntity::JSON_T_FLOAT:
			_data.push_back(val.toFloat());
			break;
		case JSONEntity::JSON_T_TRUE:
			_data.push_back(true);
			break;
		case JSONEntity::JSON_T_FALSE:
			_data.push_back(false);
			break;
		case JSONEntity::JSON_T_NULL:
			_data.push_back(Var());
			break;
		default:
			throw Poco::InvalidArgumentException("Unknown type.");
		}
	}
}
Beispiel #2
0
void JSONHandler::handle(const JSONEntity& value)
{
	switch(value.type())
	{
	case JSONEntity::JSON_T_ARRAY_BEGIN:    
		handleArrayBegin();
		setKey(false);
		incrementLevel();
		break;

	case JSONEntity::JSON_T_ARRAY_END:
		poco_assert(!isKey());
		if (level() > 0)
			decrementLevel();
		handleArrayEnd();
		break;

	case JSONEntity::JSON_T_OBJECT_BEGIN:
		handleObjectBegin();
		setKey(false);
		incrementLevel();
		break;

	case JSONEntity::JSON_T_OBJECT_END:
		poco_assert(!isKey());
		if (level() > 0)
			decrementLevel();
		handleObjectEnd();
		break;

	case JSONEntity::JSON_T_VALUE_SEPARATOR:
		handleValueSeparator();
		setKey(false);
		break;

	case JSONEntity::JSON_T_INTEGER:
		handleInteger(value);
		setKey(false);
		break;

	case JSONEntity::JSON_T_FLOAT:
		handleFloat(value);
		setKey(false);
		break;

	case JSONEntity::JSON_T_NULL:
		handleNull();
		setKey(false);
		break;

	case JSONEntity::JSON_T_TRUE:
		handleTrue();
		setKey(false);
		break;

	case JSONEntity::JSON_T_FALSE:
		handleFalse();
		setKey(false);
		break;

	case JSONEntity::JSON_T_KEY:
		setKey(true);
		handleKey(value);
		break;   

	case JSONEntity::JSON_T_STRING:
		handleString(value);
		setKey(false);
		break;

	default:
		poco_assert (false);
		break;
	}
}