module Json
  ( jsonObject
  , jsonId
  ) where

import qualified Data.Aeson.Types    as Json
import qualified Data.HashMap.Strict as M
import           Data.Int            (Int64)
import           Data.Text           (Text)
import           Web.Scotty

jsonObject :: [(Text, Json.Value)] -> ActionM ()
jsonObject = json . Json.Object . M.fromList

jsonId :: Int64 -> ActionM ()
jsonId key = json . Json.Object . M.fromList $ [("id", Json.Number . fromIntegral $ key)]