aeson-casing-0.1.0.1: Tools to change the formatting of field names in Aeson instances.

Safe HaskellNone
LanguageHaskell2010

Data.Aeson.Casing.Internal

Synopsis

Documentation

aesonDrop :: Int -> (String -> String) -> Options Source

Creates an Aeson options object that drops a specific number of characters from the front of a field name, then applies a casing function.

aesonPrefix :: (String -> String) -> Options Source

Creates an Aeson options object that drops the field name prefix from a field, then applies a casing function. We assume a convention of the prefix always being lower case, and the first letter of the actual field name being uppercase. This accommodated for field names in GHC 7.8 and below.

data Person = Person
       { personFirstName :: Text
       , personLastName  :: Text
       } deriving (Generic)

data Dog = Dog
       { dogFirstName :: Text
       } deriving (Generic)

In the above cases, dog and person are always dropped from the JSON field names.

snakeCase :: String -> String Source

Snake casing, where the words are always lower case and separated by an underscore.

camelCase :: String -> String Source

Camel casing, where the words are separated by the first letter of each word being a capitol. However, the first letter of the field is never a capitol.

pascalCase :: String -> String Source

Pascal casing, where the words are separated by the first letter of each word being a capitol. The first letter of the field is always a capitol.