Skip to content

Commit

Permalink
An obvious simplification that potentially lets us avoid backtracking
Browse files Browse the repository at this point in the history
  • Loading branch information
bos committed May 24, 2011
1 parent 914bed2 commit 018ff4c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Data/Aeson/Parser.hs
Expand Up @@ -33,6 +33,7 @@ import Data.Vector as Vector hiding ((++))
import Data.Word (Word8)
import qualified Data.Attoparsec as A
import qualified Data.Attoparsec.Zepto as Z
import qualified Data.ByteString.Char8 as B8
import qualified Data.ByteString.Unsafe as B

-- | Parse a top-level JSON value. This must be either an object or
Expand Down Expand Up @@ -67,15 +68,15 @@ value :: Parser Value
value = most <|> (Number <$> number)
where
most = do
c <- anyChar
c <- satisfy (`B8.elem` "{[\"ftn")
case c of
'{' -> object_
'[' -> array_
'"' -> String <$> jstring_
'f' -> string "alse" *> pure (Bool False)
't' -> string "rue" *> pure (Bool True)
'n' -> string "ull" *> pure Null
_ -> fail "not a valid JSON value"
_ -> error "attoparsec panic! the impossible happened!"

doubleQuote, backslash :: Word8
doubleQuote = 34
Expand Down

0 comments on commit 018ff4c

Please sign in to comment.