aeson-with 0.0.1.0 → 0.1.0.0
raw patch · 3 files changed
+12/−12 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Data.Aeson.With: withValueMaybe :: Text -> Maybe Value -> Value -> Value
- Data.Aeson.With: withArrayField :: Text -> [Value] -> Value -> Value
+ Data.Aeson.With: withArrayField :: ToJSON a => Text -> [a] -> Value -> Value
- Data.Aeson.With: withValue :: Text -> Value -> Value -> Value
+ Data.Aeson.With: withValue :: ToJSON a => Text -> a -> Value -> Value
Files
- ChangeLog.md +5/−0
- aeson-with.cabal +3/−3
- src/Data/Aeson/With.hs +4/−9
ChangeLog.md view
@@ -1,5 +1,10 @@ # Changelog for aeson-with +## v0.1.0.0++* Change `withArrayField` and `withValue` to take `ToJSON` values.+* Remove `withValueMaybe`.+ ## v0.0.1.0 * Dirty aeson-with lenses for quickly adding fields to objects.
aeson-with.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.33.0.+-- This file has been generated from package.yaml by hpack version 0.33.1. -- -- see: https://github.com/sol/hpack ----- hash: 60d1cd77eef3980b26cefd6eb07c1b9e0ff54dcfa96838bfd6666cab0e858f6a+-- hash: 1ee92e1f825a8b020fcedaea82e7dbc3f62b20bdb5a6731b26dac5b9a3e64ff6 name: aeson-with-version: 0.0.1.0+version: 0.1.0.0 synopsis: withXField combinators for aeson description: Silly little withXField combinators for adding fields to an existing JSON value. category: Data
src/Data/Aeson/With.hs view
@@ -2,7 +2,6 @@ module Data.Aeson.With ( withJSON , withValue-, withValueMaybe , withStringField , withArrayField , withObjectField@@ -34,16 +33,12 @@ withStringField f v = _Object . at f ?~ String v -- | Add an Array field to a JSON value.-withArrayField :: Text -> [Value] -> Value -> Value-withArrayField f v = _Object . at f ?~ Array (V.fromList v)+withArrayField :: ToJSON a => Text -> [a] -> Value -> Value+withArrayField f v = _Object . at f ?~ Array (V.fromList (toJSON <$> v)) -- | Add an Value field to a JSON value.-withValue :: Text -> Value -> Value -> Value-withValue f v = _Object . at f ?~ v---- | Maybe add a Value to a JSON object.-withValueMaybe :: Text -> Maybe Value -> Value -> Value-withValueMaybe f v = _Object . at f .~ v+withValue :: ToJSON a => Text -> a -> Value -> Value+withValue f v = _Object . at f ?~ (toJSON v) -- | Add an Number field to a JSON value. withNumberField :: Text -> Scientific -> Value -> Value