waargonaut-0.8.0.2: JSON wrangling
Safe HaskellNone
LanguageHaskell2010

Waargonaut.Encode.Builder.JString

Description

Builder structures for JStrings

Synopsis

Documentation

jStringBuilder :: Monoid b => Builder t b -> JString -> b Source #

Builder for a JString.

>>> toLazyText $ jStringBuilder textBuilder ((JString' V.empty) :: JString)
"\"\""
>>> toLazyText $ jStringBuilder textBuilder ((JString' $ V.fromList [UnescapedJChar (Unescaped 'a'),UnescapedJChar (Unescaped 'b'),UnescapedJChar (Unescaped 'c')]) :: JString)
"\"abc\""
>>> toLazyText $ jStringBuilder textBuilder ((JString' $ V.fromList [UnescapedJChar (Unescaped 'a'),EscapedJChar (WhiteSpace CarriageReturn),UnescapedJChar (Unescaped 'b'),UnescapedJChar (Unescaped 'c')]) :: JString)
"\"a\\rbc\""
>>> toLazyText $ jStringBuilder textBuilder ((JString' $ V.fromList [UnescapedJChar (Unescaped 'a'),EscapedJChar (WhiteSpace CarriageReturn),UnescapedJChar (Unescaped 'b'),UnescapedJChar (Unescaped 'c'),EscapedJChar (Hex (HexDigit4 HeXDigita HeXDigitb HeXDigit1 HeXDigit2)),EscapedJChar (WhiteSpace NewLine),UnescapedJChar (Unescaped 'd'),UnescapedJChar (Unescaped 'e'),UnescapedJChar (Unescaped 'f'),EscapedJChar QuotationMark]) :: JString)
"\"a\\rbc\\uab12\\ndef\\\"\""
>>> toLazyText $ jStringBuilder textBuilder ((JString' $ V.singleton (UnescapedJChar (Unescaped 'a'))) :: JString)
"\"a\""
>>> toLazyText $ jStringBuilder textBuilder (JString' $ V.singleton (EscapedJChar ReverseSolidus) :: JString)
"\"\\\\\""