-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Parse and render JSON simply. -- -- Derulo parses and renders JSON simply. @package derulo @version 1.0.2 -- | Derulo parses and renders JSON simply. It aims to provide an RFC 7159 -- compliant parser and renderer without incurring any dependencies. It -- is intended to be used either for learning or in situations where -- dependencies are unwanted. In normal usage, prefer a faster, more -- robust library like Aeson. -- -- Derulo does not export any identifiers that conflict with the prelude -- and can be imported unqualified. -- --
-- >>> import Derulo ---- -- Use readJSON to parse a String into a JSON value. -- --
-- >>> readJSON " null " -- Just Null ---- -- Use showJSON to render a JSON value as a String. -- --
-- >>> showJSON Null -- "null" --module Derulo -- | A JSON value as described by RFC 7159. data JSON Null :: JSON Boolean :: Bool -> JSON Number :: Integer -> Integer -> JSON String :: String -> JSON Array :: [JSON] -> JSON Object :: [(String, JSON)] -> JSON -- | Parses a string as JSON. -- --
-- >>> readJSON "null" -- Just Null ---- --
-- >>> readJSON "true" -- Just (Boolean True) -- -- >>> readJSON "false" -- Just (Boolean False) ---- --
-- >>> readJSON "0e0" -- Just (Number 0 0) -- -- >>> readJSON "12e34" -- Just (Number 12 34) -- -- >>> readJSON "-12e-34" -- Just (Number (-12) (-34)) ---- --
-- >>> readJSON "\"\"" -- Just (String "") -- -- >>> readJSON "\"js\"" -- Just (String "js") -- -- >>> readJSON "\"\\\"\\\\\\b\\f\\n\\r\\t\"" -- Just (String "\"\\\b\f\n\r\t") -- -- >>> readJSON "\"\\u001f\"" -- Just (String "\US") ---- --
-- >>> readJSON "[]" -- Just (Array []) -- -- >>> readJSON "[null]" -- Just (Array [Null]) -- -- >>> readJSON "[true,false]" -- Just (Array [Boolean True,Boolean False]) ---- --
-- >>> readJSON "{}"
-- Just (Object [])
--
-- >>> readJSON "{\"\":null}"
-- Just (Object [("",Null)])
--
-- >>> readJSON "{\"t\":true,\"f\":false}"
-- Just (Object [("t",Boolean True),("f",Boolean False)])
--
readJSON :: String -> Maybe JSON
-- | Renders JSON as a string.
--
-- -- >>> showJSON Null -- "null" ---- --
-- >>> showJSON (Boolean True) -- "true" -- -- >>> showJSON (Boolean False) -- "false" ---- --
-- >>> showJSON (Number 0 0) -- "0e0" -- -- >>> showJSON (Number 12 34) -- "12e34" -- -- >>> showJSON (Number (-12) (-34)) -- "-12e-34" ---- --
-- >>> showJSON (String "") -- "\"\"" -- -- >>> showJSON (String "js") -- "\"js\"" -- -- >>> showJSON (String "\"\\\b\f\n\r\t") -- "\"\\\"\\\\\\b\\f\\n\\r\\t\"" -- -- >>> showJSON (String "\x1f") -- "\"\\u001f\"" ---- --
-- >>> showJSON (Array []) -- "[]" -- -- >>> showJSON (Array [Null]) -- "[null]" -- -- >>> showJSON (Array [Boolean True, Boolean False]) -- "[true,false]" ---- --
-- >>> showJSON (Object [])
-- "{}"
--
-- >>> showJSON (Object [("", Null)])
-- "{\"\":null}"
--
-- >>> showJSON (Object [("t", Boolean True), ("f", Boolean False)])
-- "{\"t\":true,\"f\":false}"
--
showJSON :: JSON -> String
instance GHC.Show.Show Derulo.JSON
instance GHC.Read.Read Derulo.JSON
instance GHC.Classes.Ord Derulo.JSON
instance GHC.Generics.Generic Derulo.JSON
instance GHC.Classes.Eq Derulo.JSON
instance Data.Data.Data Derulo.JSON