Commits

Bryan O'Sullivan  committed 841d43c

Add some convenience values.

  • Participants
  • Parent commits d4eecdc

Comments (0)

Files changed (1)

File Data/Aeson/Types.hs

     -- * Core JSON types
       Value(..)
     , Array
+    , emptyArray
     , Object
+    , emptyObject
     -- * Type conversion
     , FromJSON(..)
     , ToJSON(..)
 import qualified Data.Map as M
 import qualified Data.Vector as V
 
+-- | A JSON \"object\" (key/value map).
 type Object = Map Text Value
+
+-- | A JSON \"array\" (sequence).
 type Array = Vector Value
 
 -- | A JSON value represented as a Haskell value.
     rnf (Bool b)   = rnf b
     rnf Null       = ()
 
+-- | The empty array.
+emptyArray :: Value
+emptyArray = Array V.empty
+
+-- | The empty object.
+emptyObject :: Value
+emptyObject = Object M.empty
+
 -- | Construct an 'Object' from a key and a value.
 (.=) :: ToJSON a => Text -> a -> Object
 name .= value = M.singleton name (toJSON value)