Safe Haskell | None |
---|---|
Language | Haskell2010 |
Types and functions for handling escaped characters in JSON.
Synopsis
- data Escaped digit
- = QuotationMark
- | ReverseSolidus
- | Solidus
- | Backspace
- | WhiteSpace Whitespace
- | Hex (HexDigit4 digit)
- class AsEscaped r digit | r -> digit where
- _Escaped :: Prism' r (Escaped digit)
- _QuotationMark :: Prism' r ()
- _ReverseSolidus :: Prism' r ()
- _Solidus :: Prism' r ()
- _Backspace :: Prism' r ()
- _WhiteSpace :: Prism' r Whitespace
- _Hex :: Prism' r (HexDigit4 digit)
- parseEscaped :: (CharParsing f, HeXaDeCiMaL digit) => f (Escaped digit)
- escapedToChar :: Escaped HeXDigit -> Char
- charToEscaped :: Char -> Maybe (Escaped HeXDigit)
Types
Things that may be escaped in a JSON string.
Instances
class AsEscaped r digit | r -> digit where Source #
Typeclass for things that may be used as an escaped JChar.
_Escaped :: Prism' r (Escaped digit) Source #
_QuotationMark :: Prism' r () Source #
_ReverseSolidus :: Prism' r () Source #
_Solidus :: Prism' r () Source #
_Backspace :: Prism' r () Source #
_WhiteSpace :: Prism' r Whitespace Source #
Instances
AsEscaped (Escaped digit) digit Source # | |
Defined in Waargonaut.Types.JChar.Escaped _Escaped :: Prism' (Escaped digit) (Escaped digit) Source # _QuotationMark :: Prism' (Escaped digit) () Source # _ReverseSolidus :: Prism' (Escaped digit) () Source # _Solidus :: Prism' (Escaped digit) () Source # _Backspace :: Prism' (Escaped digit) () Source # _WhiteSpace :: Prism' (Escaped digit) Whitespace Source # | |
AsEscaped (JChar digit) digit Source # | |
Defined in Waargonaut.Types.JChar _Escaped :: Prism' (JChar digit) (Escaped digit) Source # _QuotationMark :: Prism' (JChar digit) () Source # _ReverseSolidus :: Prism' (JChar digit) () Source # _Solidus :: Prism' (JChar digit) () Source # _Backspace :: Prism' (JChar digit) () Source # _WhiteSpace :: Prism' (JChar digit) Whitespace Source # |
Parser
parseEscaped :: (CharParsing f, HeXaDeCiMaL digit) => f (Escaped digit) Source #
Parse an escapted JSON character.
>>>
testparse parseEscaped "\\\""
Right QuotationMark
>>>
testparse parseEscaped "\\\\"
Right ReverseSolidus
>>>
testparse parseEscaped "\\/"
Right Solidus
>>>
testparse parseEscaped "\\b"
Right Backspace
>>>
testparse parseEscaped "\\f"
Right (WhiteSpace LineFeed)
>>>
testparse parseEscaped "\\n"
Right (WhiteSpace NewLine)
>>>
testparse parseEscaped "\\r"
Right (WhiteSpace CarriageReturn)
>>>
testparse parseEscaped "\\t"
Right (WhiteSpace HorizontalTab)
>>>
testparse parseEscaped "\\u1234" :: Either DecodeError (Escaped HeXDigit)
Right (Hex (HexDigit4 HeXDigit1 HeXDigit2 HeXDigit3 HeXDigit4))
>>>
testparsetheneof parseEscaped "\\t"
Right (WhiteSpace HorizontalTab)
>>>
testparsethennoteof parseEscaped "\\tx"
Right (WhiteSpace HorizontalTab)