From da1f712c385b0f000845dfcf52f5a43288d8feab Mon Sep 17 00:00:00 2001 From: Kasper Jeppesen Date: Thu, 4 May 2017 10:05:14 -0700 Subject: [PATCH] change getInt semantics --- src/main/java/me/doubledutch/lazyjson/LazyNode.java | 8 ++++++-- src/main/resources/lazyjson_version.properties | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/doubledutch/lazyjson/LazyNode.java b/src/main/java/me/doubledutch/lazyjson/LazyNode.java index 6dae59e..8f9a773 100644 --- a/src/main/java/me/doubledutch/lazyjson/LazyNode.java +++ b/src/main/java/me/doubledutch/lazyjson/LazyNode.java @@ -227,7 +227,9 @@ protected int getIntValue() throws LazyException{ int i=startIndex; boolean sign=false; int value=0; - if(type==VALUE_STRING || type==VALUE_ESTRING){ + if(type==VALUE_FLOAT){ + return (int)getDoubleValue(); + }else if(type==VALUE_STRING || type==VALUE_ESTRING){ // Attempt to parse as an int, throw if impossible if(dirty){ if(dirtyBuf.charAt(i)=='-'){ @@ -303,7 +305,9 @@ protected long getLongValue() throws LazyException{ int i=startIndex; boolean sign=false; long value=0; - if(type==VALUE_STRING || type==VALUE_ESTRING){ + if(type==VALUE_FLOAT){ + return (long)getDoubleValue(); + }else if(type==VALUE_STRING || type==VALUE_ESTRING){ // Attempt to parse as an int, throw if impossible if(dirty){ if(dirtyBuf.charAt(i)=='-'){ diff --git a/src/main/resources/lazyjson_version.properties b/src/main/resources/lazyjson_version.properties index 27e7d37..d40d9aa 100644 --- a/src/main/resources/lazyjson_version.properties +++ b/src/main/resources/lazyjson_version.properties @@ -1,4 +1,4 @@ -#Wed May 03 14:15:00 PDT 2017 +#Wed May 03 16:52:48 PDT 2017 BUILD_VERSION=2.2.1 -BUILD_DATE=2017-05-03T21\:15\:00Z -BUILD_NUMBER=993 +BUILD_DATE=2017-05-03T23\:52\:48Z +BUILD_NUMBER=1042