Safe Haskell | None |
---|---|
Language | Haskell2010 |
Module representing a JSON-API meta object.
Specification: http://jsonapi.org/format/#document-meta
Synopsis
- data Meta
- class ToJSON a => MetaObject a where
- data Pagination = Pagination {
- pageSize :: Maybe Int
- currentPage :: Maybe Int
- totalDocuments :: Maybe Int
- mkMeta :: MetaObject a => a -> Meta
Documentation
Type representing a JSON-API meta object.
Meta is an abstraction around an underlying Map consisting of resource-specific metadata.
Example JSON:
"meta": {
"copyright": "Copyright 2015 Example Corp.",
"authors": [
"Andre Dawson",
"Kirby Puckett",
"Don Mattingly",
"Ozzie Guillen"
]
}
Specification: http://jsonapi.org/format/#document-meta
class ToJSON a => MetaObject a where Source #
Convienience class for constructing a Meta type
Example usage: @ data Pagination = Pagination { currentPage :: Int , totalPages :: Int } deriving (Show, Generic)
instance ToJSON Pagination instance MetaObject Pagination where typeName _ = "pagination" @
Instances
MetaObject Pagination Source # | |
Defined in Network.JSONApi.Meta typeName :: Pagination -> Text Source # |
data Pagination Source #
Pagination is arguably a meta object not covered by the Spec. The spec instead opts for links which are supported by this library. However if you would like to throw a generic Pagination meta object into your response payload this type may be used.
Pagination | |
|
Instances
Eq Pagination Source # | |
Defined in Network.JSONApi.Meta (==) :: Pagination -> Pagination -> Bool # (/=) :: Pagination -> Pagination -> Bool # | |
Show Pagination Source # | |
Defined in Network.JSONApi.Meta showsPrec :: Int -> Pagination -> ShowS # show :: Pagination -> String # showList :: [Pagination] -> ShowS # | |
ToJSON Pagination Source # | |
Defined in Network.JSONApi.Meta toJSON :: Pagination -> Value # toEncoding :: Pagination -> Encoding # toJSONList :: [Pagination] -> Value # toEncodingList :: [Pagination] -> Encoding # | |
FromJSON Pagination Source # | |
Defined in Network.JSONApi.Meta parseJSON :: Value -> Parser Pagination # parseJSONList :: Value -> Parser [Pagination] # | |
MetaObject Pagination Source # | |
Defined in Network.JSONApi.Meta typeName :: Pagination -> Text Source # |
mkMeta :: MetaObject a => a -> Meta Source #
Convienience constructor function for the Meta type
Useful on its own or in combination with Meta's monoid instance
Example usage: See MetaSpec.hs for an example