summaryrefslogtreecommitdiff
path: root/lib/Data/Aeson/TH/Extended.hs
blob: 0fa54877773c0f6195ff4e5d555fdc9db52bb208 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
--------------------------------------------------------------------------------
module Data.Aeson.TH.Extended
    ( module Data.Aeson.TH
    , dropPrefixOptions
    ) where


--------------------------------------------------------------------------------
import           Data.Aeson.TH
import           Data.Char     (isUpper, toLower)


--------------------------------------------------------------------------------
dropPrefixOptions :: Options
dropPrefixOptions = defaultOptions
    { fieldLabelModifier = dropPrefix
    }
  where
    dropPrefix str = case break isUpper str of
        (_, (y : ys)) -> toLower y : ys
        _             -> str