diff --git a/JSON/src/Parser.cpp b/JSON/src/Parser.cpp index 469a46684..b96fc586e 100644 --- a/JSON/src/Parser.cpp +++ b/JSON/src/Parser.cpp @@ -19,11 +19,13 @@ #include "Poco/Ascii.h" #include "Poco/Token.h" #include "Poco/UTF8Encoding.h" +#include "Poco/String.h" #undef min #undef max #include #include #include +#include namespace Poco { @@ -407,9 +409,11 @@ void Parser::parseBuffer() case JSON_T_INTEGER: { #if defined(POCO_HAVE_INT64) + std::string numStr(_parseBuffer.begin(), _parseBuffer.size()); try { - Int64 value = NumberParser::parse64(std::string(_parseBuffer.begin(), _parseBuffer.size())); + Poco::trimInPlace(numStr); + Int64 value = NumberParser::parse64(numStr); // if number is 32-bit, then handle as such if (value > std::numeric_limits::max() || value < std::numeric_limits::min() ) @@ -424,7 +428,7 @@ void Parser::parseBuffer() // try to handle error as unsigned in case of overflow catch ( const SyntaxException& ) { - UInt64 value = NumberParser::parseUnsigned64(std::string(_parseBuffer.begin(), _parseBuffer.size())); + UInt64 value = NumberParser::parseUnsigned64(numStr); // if number is 32-bit, then handle as such if ( value > std::numeric_limits::max() ) { @@ -438,13 +442,13 @@ void Parser::parseBuffer() #else try { - int value = NumberParser::parse(std::string(_parseBuffer.begin(), _parseBuffer.size())); + int value = NumberParser::parse(numStr); _pHandler->value(value); } // try to handle error as unsigned in case of overflow catch ( const SyntaxException& ) { - unsigned value = NumberParser::parseUnsigned(std::string(_parseBuffer.begin(), _parseBuffer.size())); + unsigned value = NumberParser::parseUnsigned(numStr); _pHandler->value(value); } #endif