Update JSON parser to correctly handle 64-bit integers

This commit is contained in:
Mike Naquin 2012-12-13 09:39:50 -06:00
parent 27616fb0e6
commit d5858c15d4

View File

@ -575,18 +575,20 @@ void Parser::readValue(const Token* token)
case Token::INTEGER_LITERAL_TOKEN:
if ( _handler != NULL )
{
int value = token->asInteger();
#if defined(POCO_HAVE_INT64)
if ( value == std::numeric_limits<int>::max()
|| value == std::numeric_limits<int>::min() )
{
_handler->value(NumberParser::parse64(token->asString()));
}
else
{
_handler->value(token->asInteger());
}
Int64 value = token->asInteger();
// if number is 32-bit, then handle as such
if ( value > std::numeric_limits<int>::max()
|| value < std::numeric_limits<int>::min() )
{
_handler->value(value);
}
else
{
_handler->value(static_cast<int>(value));
}
#else
int value = token->asInteger();
_handle->value(value);
#endif
}
@ -697,5 +699,4 @@ bool Parser::readElements(bool firstCall)
throw JSONException(format("Invalid token '%s' found.", token->asString()));
}
} } // namespace Poco::JSON