aeson-extra 0.5.1.2 → 0.5.1.3
raw patch · 5 files changed
+65/−12 lines, 5 filesdep +attoparsec-aesondep ~aesondep ~basedep ~bytestringPVP ok
version bump matches the API change (PVP)
Dependencies added: attoparsec-aeson
Dependency ranges changed: aeson, base, bytestring, deepseq, template-haskell, text
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−1
- aeson-extra.cabal +11/−9
- src/Data/Aeson/Extra/CollapsedList.hs +23/−0
- src/Data/Aeson/Extra/SingObject.hs +25/−1
- src/Data/Aeson/Extra/Stream.hs +1/−1
CHANGELOG.md view
@@ -1,4 +1,8 @@-# 0.5.1.1. (2022-06-15)+# 0.5.1.3 (2023-07-09)++- Support `aeson-2.2.0.0`++# 0.5.1.1 (2022-06-15) - Support `aeson-2.1.0.0` - Drop unused package dependencies
aeson-extra.cabal view
@@ -1,6 +1,6 @@ cabal-version: >=1.10 name: aeson-extra-version: 0.5.1.2+version: 0.5.1.3 synopsis: Extra goodies for aeson description: Package provides extra functionality on top of @aeson@ and @aeson-compat@@@ -22,8 +22,9 @@ || ==8.8.4 || ==8.10.7 || ==9.0.2- || ==9.2.4- || ==9.4.1+ || ==9.2.8+ || ==9.4.5+ || ==9.6.2 build-type: Simple extra-source-files:@@ -38,8 +39,9 @@ hs-source-dirs: src ghc-options: -Wall build-depends:- aeson >=1.5.4.1 && <1.6 || >=2.0 && <2.2+ aeson >=1.5.4.1 && <1.6 || >=2.0 && <2.3 , attoparsec >=0.11.3.4 && <0.15+ , attoparsec-aeson >=2.1.0.0 && <2.3 , base >=4.7 && <4.19 , base-compat-batteries >=0.11.2 && <0.14 , bytestring >=0.10 && <0.12@@ -48,7 +50,7 @@ , scientific >=0.3 && <0.4 , semialign >=1 && <1.4 , template-haskell >=2.8 && <2.21- , text >=1.2 && <1.3 || >=2.0 && <2.1+ , text >=1.2 && <1.3 || >=2.0 && <2.1 , these >=1 && <1.3 , unordered-containers >=0.2 && <0.3 , vector >=0.10 && <0.14@@ -80,10 +82,10 @@ , base , base-compat-batteries , containers- , quickcheck-instances >=0.3 && <0.4- , tasty >=0.10 && <1.5- , tasty-hunit >=0.9 && <0.11- , tasty-quickcheck >=0.8 && <0.11+ , quickcheck-instances >=0.3 && <0.4+ , tasty >=0.10 && <1.5+ , tasty-hunit >=0.9 && <0.11+ , tasty-quickcheck >=0.8 && <0.11 , unordered-containers , vector
src/Data/Aeson/Extra/CollapsedList.hs view
@@ -69,12 +69,34 @@ getCollapsedList (CollapsedList l) = l instance (FromJSON1 f, Alternative f) => FromJSON1 (CollapsedList f) where+#if MIN_VERSION_aeson(2,2,0)+ liftParseJSON o p _ v = CollapsedList <$> case v of+ Null -> pure Control.Applicative.empty+ Array _ -> liftParseJSON o p (listParser p) v+ x -> pure <$> p x+#else liftParseJSON p _ v = CollapsedList <$> case v of Null -> pure Control.Applicative.empty Array _ -> liftParseJSON p (listParser p) v x -> pure <$> p x+#endif instance (ToJSON1 f, Foldable f) => ToJSON1 (CollapsedList f) where+#if MIN_VERSION_aeson(2,2,0)+ liftToEncoding o to _ (CollapsedList l) = case l' of+ [] -> toEncoding Null+ [x] -> to x+ _ -> liftToEncoding o to (listEncoding to) l+ where+ l' = Foldable.toList l++ liftToJSON o to _ (CollapsedList l) = case l' of+ [] -> toJSON Null+ [x] -> to x+ _ -> liftToJSON o to (listValue to) l+ where+ l' = Foldable.toList l+#else liftToEncoding to _ (CollapsedList l) = case l' of [] -> toEncoding Null [x] -> to x@@ -88,6 +110,7 @@ _ -> liftToJSON to (listValue to) l where l' = Foldable.toList l+#endif instance (ToJSON1 f, Foldable f, ToJSON a) => ToJSON (CollapsedList f a) where toJSON = toJSON1
src/Data/Aeson/Extra/SingObject.hs view
@@ -25,7 +25,6 @@ import Control.DeepSeq (NFData (..)) import Data.Aeson import Data.Aeson.Encoding (pair)-import Data.Aeson.Internal (JSONPathElement (Key)) import Data.Proxy (Proxy (..)) import Data.String (fromString) import Data.Typeable (Typeable)@@ -40,6 +39,11 @@ import qualified Data.HashMap.Strict as KM #endif +#if MIN_VERSION_aeson(2,2,0)+import Data.Aeson.Types (JSONPathElement (Key))+#else+import Data.Aeson.Internal (JSONPathElement (Key))+#endif -- | Singleton value object@@ -61,14 +65,33 @@ getSingObject _ (SingObject x) = x instance KnownSymbol s => FromJSON1 (SingObject s) where+#if MIN_VERSION_aeson(2,2,0)+ liftParseJSON _ p _ = withObject ("SingObject "<> show key) $ \obj ->+ case KM.lookup key obj of+ Nothing -> fail $ "key " ++ show key ++ " not present"+ Just v -> SingObject <$> p v <?> Key key+ where+ key = fromString $ symbolVal (Proxy :: Proxy s)+#else liftParseJSON p _ = withObject ("SingObject "<> show key) $ \obj -> case KM.lookup key obj of Nothing -> fail $ "key " ++ show key ++ " not present" Just v -> SingObject <$> p v <?> Key key where key = fromString $ symbolVal (Proxy :: Proxy s)+#endif instance KnownSymbol s => ToJSON1 (SingObject s) where+#if MIN_VERSION_aeson(2,2,0)+ liftToJSON _ to _ (SingObject x) =+ object [ key .= to x]+ where+ key = fromString $ symbolVal (Proxy :: Proxy s)+ liftToEncoding _ to _ (SingObject x) =+ pairs $ pair key $ to x+ where+ key = fromString $ symbolVal (Proxy :: Proxy s)+#else liftToJSON to _ (SingObject x) = object [ key .= to x] where@@ -77,6 +100,7 @@ pairs $ pair key $ to x where key = fromString $ symbolVal (Proxy :: Proxy s)+#endif instance (KnownSymbol s, FromJSON a) => FromJSON (SingObject s a) where parseJSON = parseJSON1
src/Data/Aeson/Extra/Stream.hs view
@@ -8,7 +8,7 @@ -- module Data.Aeson.Extra.Stream ( streamDecode,- ) where+) where import Prelude () import Prelude.Compat