Skip to content

Commit

Permalink
Fix isjson check in sniff.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj committed Dec 15, 2017
1 parent 5457809 commit 53e32d4
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/sniff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,19 @@ function isjson(bytes, i=0, maxlen=min(length(bytes), MAXSNIFFLENGTH))
end
elseif b == OPEN_SQUARE_BRACE
# '[' start of array
# recursively check `isjson`, then potential whitespace, then ',' or ']'
while true
ret, i = isjson(bytes, i, maxlen)
ret || return false, i
eof, b, i = ignorewhitespace(bytes, i, maxlen)
(eof || b == CLOSE_SQUARE_BRACE) && return true, i
b != COMMA && return false, i
# peek at next byte to check for empty array
ia = i
eof, b, i = nextbyte(bytes, i, maxlen)
if b != CLOSE_SQUARE_BRACE
i = ia
# recursively check `isjson`, then potential whitespace, then ',' or ']'
while true
ret, i = isjson(bytes, i, maxlen)
ret || return false, i
eof, b, i = ignorewhitespace(bytes, i, maxlen)
(eof || b == CLOSE_SQUARE_BRACE) && return true, i
b != COMMA && return false, i
end
end
elseif b == DOUBLE_QUOTE
# '"' start of string
Expand Down

0 comments on commit 53e32d4

Please sign in to comment.