servant-auth-token-api-0.5.4.0: Servant based API for token based authorisation

Copyright(c) Anton Gushcha 2016
LicenseMIT
Maintainerncrashed@gmail.com
Stabilityexperimental
PortabilityPortable
Safe HaskellNone
LanguageHaskell2010

Servant.API.Auth.Token.Internal.DeriveJson

Description

Common usage:

data PagedList i a = PagedList {
  pagedListItems :: ![a] -- ^ Payload
, pagedListPages :: !Word -- ^ Count of available pages
} deriving (Generic, Show)

$(deriveJSON (derivePrefix "pagedList") ''PagedList)

It will work with the following jsons:

{ "items": [], "pages": 0 }
Synopsis

Documentation

derivePrefix :: Text -> Options Source #

For aeson deriving, drop prefix t and map to lower

deriveJSON #

Arguments

:: Options

Encoding options.

-> Name

Name of the type for which to generate JSONFun and FromJSON instances.

-> Q [Dec] 

Generates both JSONFun and FromJSON instance declarations for the given data type or data family instance constructor.

This is a convienience function which is equivalent to calling both deriveToJSON and deriveFromJSON.