Safe Haskell | None |
---|---|
Language | Haskell2010 |
JSON Array representation and functions.
Synopsis
- newtype JArray ws a = JArray (CommaSeparated ws a)
- parseJArray :: (Monad f, CharParsing f) => f ws -> f a -> f (JArray ws a)
Types
Conveniently, a JSON array is a CommaSeparated
list with an optional
trailing comma, some instances and other functions need to work differently so
we wrap it up in a newtype.
JArray (CommaSeparated ws a) |
Instances
Parser
parseJArray :: (Monad f, CharParsing f) => f ws -> f a -> f (JArray ws a) Source #
Parse a single JSON array
>>>
testparse (parseJArray parseWhitespace parseWaargonaut) "[null ]"
Right (JArray (CommaSeparated (WS []) (Just (Elems {_elemsElems = [], _elemsLast = Elem {_elemVal = Json (JNull (WS [Space])), _elemTrailing = Nothing}}))))
>>>
testparse (parseJArray parseWhitespace parseWaargonaut) "[null,]"
Right (JArray (CommaSeparated (WS []) (Just (Elems {_elemsElems = [], _elemsLast = Elem {_elemVal = Json (JNull (WS [])), _elemTrailing = Just (Comma,WS [])}}))))