summaryrefslogtreecommitdiff
path: root/lib/Data/Aeson/TH/Extended.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/Aeson/TH/Extended.hs')
-rw-r--r--lib/Data/Aeson/TH/Extended.hs21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/Data/Aeson/TH/Extended.hs b/lib/Data/Aeson/TH/Extended.hs
new file mode 100644
index 0000000..0fa5487
--- /dev/null
+++ b/lib/Data/Aeson/TH/Extended.hs
@@ -0,0 +1,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