From 05000cfbdff326c03a4d81e82840cccf8722fe4a Mon Sep 17 00:00:00 2001 From: Avik Sengupta Date: Thu, 6 Jun 2013 00:42:07 +0100 Subject: [PATCH] fix #26 --- src/Parser.jl | 15 ++++++++------- test/JSON.jl | 5 +++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Parser.jl b/src/Parser.jl index e63f22d..1ecbba5 100644 --- a/src/Parser.jl +++ b/src/Parser.jl @@ -410,10 +410,10 @@ module Parser if str[p] == '0' p += 1 if str[p] == '.' - is_decimal = true + is_float = true p += 1 else - is_decimal = false + is_float = false end elseif str[p] > '0' && str[p] <= '9' p += 1 @@ -423,9 +423,9 @@ module Parser end if str[p] == '.' p += 1 - is_decimal = true + is_float = true else - is_decimal = false + is_float = false end else _error( @@ -433,7 +433,7 @@ module Parser str, p, e ) end - if is_decimal + if is_float # Match digits after decimal while str[p] >= '0' && str[p] <= '9' p += 1 @@ -441,8 +441,9 @@ module Parser else # Not decimal end - if str[p] == 'E' || str[p] == 'e' + if str[p] == 'E' || str[p] == 'e' || str[p] == 'f' p += 1 + is_float = true # Exponent sign if str[p] == '-' || str[p] == '+' p += 1 @@ -454,7 +455,7 @@ module Parser end vs = str[s:p - 1] - if is_decimal + if is_float v = parsefloat(vs) else v = parseint(vs) diff --git a/test/JSON.jl b/test/JSON.jl index bcd2072..9417a72 100644 --- a/test/JSON.jl +++ b/test/JSON.jl @@ -152,3 +152,8 @@ fetch(finished_async_tests) # Printing an empty array or Dict shouldn't cause a BoundsError @assert JSON.to_json(ASCIIString[]) == "[]" @assert JSON.to_json(Dict()) == "{}" + +#test for issue 26 +obj = JSON.parse("{\"a\":2e10}") +@assert(obj["a"] == 2e10) +