module Data.Aeson.TH.Extended
( module Data.Aeson.TH
, dropPrefixOptions
) where
import Data.Aeson.TH
import Data.Char (isUpper, toLower)
dropPrefixOptions :: Options
dropPrefixOptions :: Options
dropPrefixOptions = Options
defaultOptions
{ fieldLabelModifier :: String -> String
fieldLabelModifier = String -> String
dropPrefix
}
where
dropPrefix :: String -> String
dropPrefix String
str = case forall a. (a -> Bool) -> [a] -> ([a], [a])
break Char -> Bool
isUpper String
str of
(String
_, (Char
y : String
ys)) -> Char -> Char
toLower Char
y forall a. a -> [a] -> [a]
: String
ys
(String, String)
_ -> String
str