module Web.Telegram.API.Bot.JsonExt
(
toJsonDrop,
parseJsonDrop
) where
import Data.Aeson
import Data.Aeson.Types
import GHC.Generics
toJsonDrop :: forall a.(Generic a, GToJSON Zero (Rep a)) => Int -> a -> Value
toJsonDrop prefix = genericToJSON defaultOptions {
fieldLabelModifier = drop prefix
, omitNothingFields = True
}
parseJsonDrop :: forall a.(Generic a, GFromJSON Zero (Rep a)) => Int -> Value -> Parser a
parseJsonDrop prefix = genericParseJSON defaultOptions { fieldLabelModifier = drop prefix }