module Buttplug.Core.Internal.JSONUtils where
import Data.Aeson (Options(..), defaultOptions, JSONKeyOptions(..), defaultJSONKeyOptions)
import Data.Aeson.Casing
stripPrefix :: String -> String -> String
stripPrefix :: String -> String -> String
stripPrefix String
s = Int -> String -> String
forall a. Int -> [a] -> [a]
drop (Int -> String -> String) -> Int -> String -> String
forall a b. (a -> b) -> a -> b
$ String -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
s
stripPrefixOptions :: String -> Options
stripPrefixOptions String
s = Options
defaultOptions { fieldLabelModifier :: String -> String
fieldLabelModifier = String -> String -> String
stripPrefix String
s }
stripPrefixKeyOptions :: String -> JSONKeyOptions
stripPrefixKeyOptions String
s = JSONKeyOptions
defaultJSONKeyOptions { keyModifier :: String -> String
keyModifier = String -> String -> String
stripPrefix String
s }
pascalCaseOptions :: Options
pascalCaseOptions :: Options
pascalCaseOptions = Options
defaultOptions { fieldLabelModifier :: String -> String
fieldLabelModifier = String -> String
pascalCase }
pascalCaseKeyOptions :: JSONKeyOptions
pascalCaseKeyOptions :: JSONKeyOptions
pascalCaseKeyOptions = JSONKeyOptions
defaultJSONKeyOptions { keyModifier :: String -> String
keyModifier = String -> String
pascalCase }
deviceMessageOptions :: Options
deviceMessageOptions :: Options
deviceMessageOptions =
Options
defaultOptions { constructorTagModifier :: String -> String
constructorTagModifier = String -> String -> String
stripPrefix String
"Dev" }
msgAttributeOptions :: Options
msgAttributeOptions :: Options
msgAttributeOptions =
Options
defaultOptions { omitNothingFields :: Bool
omitNothingFields = Bool
True
, fieldLabelModifier :: String -> String
fieldLabelModifier = String -> String
pascalCase (String -> String) -> (String -> String) -> String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String -> String
stripPrefix String
"attr"}