-- 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.5


-- | 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 <a>Aeson</a>.
--   
--   Derulo does not export any identifiers that conflict with the prelude
--   and can be imported unqualified.
--   
--   <pre>
--   &gt;&gt;&gt; import Derulo
--   </pre>
--   
--   Use <a>readJSON</a> to parse a <a>JSON</a> into a <a>JSON</a> value.
--   
--   <pre>
--   &gt;&gt;&gt; readJSON " null "
--   Just Null
--   </pre>
--   
--   Use <a>showJSON</a> to render a <a>JSON</a> value as a <a>JSON</a>.
--   
--   <pre>
--   &gt;&gt;&gt; showJSON Null
--   "null"
--   </pre>
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.
--   
--   <pre>
--   &gt;&gt;&gt; readJSON "null"
--   Just Null
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; readJSON "true"
--   Just (Boolean True)
--   
--   &gt;&gt;&gt; readJSON "false"
--   Just (Boolean False)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; readJSON "0e0"
--   Just (Number 0 0)
--   
--   &gt;&gt;&gt; readJSON "12e34"
--   Just (Number 12 34)
--   
--   &gt;&gt;&gt; readJSON "-12e-34"
--   Just (Number (-12) (-34))
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; readJSON "\"\""
--   Just (String "")
--   
--   &gt;&gt;&gt; readJSON "\"js\""
--   Just (String "js")
--   
--   &gt;&gt;&gt; readJSON "\"\\\"\\\\\\b\\f\\n\\r\\t\""
--   Just (String "\"\\\b\f\n\r\t")
--   
--   &gt;&gt;&gt; readJSON "\"\\u001f\""
--   Just (String "\US")
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; readJSON "[]"
--   Just (Array [])
--   
--   &gt;&gt;&gt; readJSON "[null]"
--   Just (Array [Null])
--   
--   &gt;&gt;&gt; readJSON "[true,false]"
--   Just (Array [Boolean True,Boolean False])
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; readJSON "{}"
--   Just (Object [])
--   
--   &gt;&gt;&gt; readJSON "{\"\":null}"
--   Just (Object [("",Null)])
--   
--   &gt;&gt;&gt; readJSON "{\"t\":true,\"f\":false}"
--   Just (Object [("t",Boolean True),("f",Boolean False)])
--   </pre>
readJSON :: String -> Maybe JSON

-- | Renders JSON as a string.
--   
--   <pre>
--   &gt;&gt;&gt; showJSON Null
--   "null"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; showJSON (Boolean True)
--   "true"
--   
--   &gt;&gt;&gt; showJSON (Boolean False)
--   "false"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; showJSON (Number 0 0)
--   "0e0"
--   
--   &gt;&gt;&gt; showJSON (Number 12 34)
--   "12e34"
--   
--   &gt;&gt;&gt; showJSON (Number (-12) (-34))
--   "-12e-34"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; showJSON (String "")
--   "\"\""
--   
--   &gt;&gt;&gt; showJSON (String "js")
--   "\"js\""
--   
--   &gt;&gt;&gt; showJSON (String "\"\\\b\f\n\r\t")
--   "\"\\\"\\\\\\b\\f\\n\\r\\t\""
--   
--   &gt;&gt;&gt; showJSON (String "\x1f")
--   "\"\\u001f\""
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; showJSON (Array [])
--   "[]"
--   
--   &gt;&gt;&gt; showJSON (Array [Null])
--   "[null]"
--   
--   &gt;&gt;&gt; showJSON (Array [Boolean True, Boolean False])
--   "[true,false]"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; showJSON (Object [])
--   "{}"
--   
--   &gt;&gt;&gt; showJSON (Object [("", Null)])
--   "{\"\":null}"
--   
--   &gt;&gt;&gt; showJSON (Object [("t", Boolean True), ("f", Boolean False)])
--   "{\"t\":true,\"f\":false}"
--   </pre>
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
