aboutsummaryrefslogtreecommitdiff
path: root/server/src/Json.hs
blob: 6d40305ddb1a00b0f31c34d5febd88ca704c7f87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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)]