Ensure JSON payload objects all have same keys

This commit is contained in:
Joe Nelson
2015-11-22 13:51:46 -08:00
parent 60007b5f10
commit 1f6fc5cbd8
3 changed files with 63 additions and 29 deletions
+7 -1
View File
@@ -3,6 +3,7 @@ import Data.Text
import Data.Tree
import qualified Data.ByteString.Lazy as BL
import qualified Data.ByteString as BS
import qualified Data.Vector as V
import Data.Aeson
data DbStructure = DbStructure {
@@ -84,10 +85,15 @@ data Relation = Relation {
, relLCols2 :: Maybe [Column]
} deriving (Show, Eq)
-- | An array of JSON objects that has been verified to have
-- the same keys in every object
newtype UniformObjects = UniformObjects (V.Vector Object)
deriving (Show, Eq)
-- | When Hasql supports the COPY command then we can
-- have a special payload just for CSV, but until
-- then CSV is converted to a JSON array.
data Payload = PayloadJSON Array
data Payload = PayloadJSON UniformObjects
| PayloadParseError BS.ByteString
deriving (Show, Eq)