From d4b4fac59f9312e6701a89d9d85440cffa014614 Mon Sep 17 00:00:00 2001 From: petru Date: Mon, 21 Dec 2015 16:14:17 +0200 Subject: [PATCH] GET_NUMBER --- Jzon.cpp | 9 ++++++--- Jzon.h | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Jzon.cpp b/Jzon.cpp index a214ee4..ff68893 100644 --- a/Jzon.cpp +++ b/Jzon.cpp @@ -144,12 +144,15 @@ namespace Jzon } } #define GET_NUMBER(T) \ - if (isNumber())\ + if (isValue())\ {\ std::stringstream sstr(data->valueStr);\ - T val;\ + double val;\ + std::string remain;\ sstr >> val;\ - return val;\ + if(sstr.fail()) return def;\ + sstr >> remain;\ + return remain.empty() ? val : def;\ }\ else\ {\ diff --git a/Jzon.h b/Jzon.h index 901ebed..caec9d0 100644 --- a/Jzon.h +++ b/Jzon.h @@ -29,6 +29,7 @@ THE SOFTWARE. #include #include + #ifndef JZON_API # ifdef JZON_DLL # if defined _WIN32 || defined __CYGWIN__