Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
aviks committed Jun 5, 2013
1 parent 816062f commit 05000cf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/Parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -423,26 +423,27 @@ module Parser
end
if str[p] == '.'
p += 1
is_decimal = true
is_float = true
else
is_decimal = false
is_float = false
end
else
_error(
"Unrecognized number",
str, p, e
)
end
if is_decimal
if is_float
# Match digits after decimal
while str[p] >= '0' && str[p] <= '9'
p += 1
end
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
Expand All @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions test/JSON.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 05000cf

Please sign in to comment.