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)
- jArrayBuilder :: (ws -> Builder) -> ((ws -> Builder) -> a -> Builder) -> JArray ws a -> Builder
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 / Builder
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 [])}}))))