aeson-result 0.1.0.0 → 0.2.0.0
raw patch · 2 files changed
+7/−7 lines, 2 filesdep ~aesonPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: aeson
API changes (from Hackage documentation)
- Data.Aeson.Result: fromList :: ToJSON a => Text -> List a -> Value
+ Data.Aeson.Result: fromList :: ToJSON a => Key -> List a -> Value
- Data.Aeson.Result: fromOk :: ToJSON a => Text -> Ok a -> Value
+ Data.Aeson.Result: fromOk :: ToJSON a => Key -> Ok a -> Value
- Data.Aeson.Result: toList :: FromJSON a => Text -> Value -> Maybe (List a)
+ Data.Aeson.Result: toList :: FromJSON a => Key -> Value -> Maybe (List a)
- Data.Aeson.Result: toOk :: FromJSON a => Text -> Value -> Maybe (Ok a)
+ Data.Aeson.Result: toOk :: FromJSON a => Key -> Value -> Maybe (Ok a)
Files
- aeson-result.cabal +2/−2
- src/Data/Aeson/Result.hs +5/−5
aeson-result.cabal view
@@ -1,5 +1,5 @@ name: aeson-result-version: 0.1.0.0+version: 0.2.0.0 synopsis: API Result for aeson description: API Result for aeson. Make json rest ful api stand. homepage: https://github.com/Lupino/yuntan-common/tree/master/aeson-result#readme@@ -17,7 +17,7 @@ hs-source-dirs: src exposed-modules: Data.Aeson.Result build-depends: base >= 4.7 && < 5- , aeson+ , aeson >= 2.0 , text , aeson-helper default-language: Haskell2010
src/Data/Aeson/Result.hs view
@@ -26,8 +26,8 @@ Value, fromJSON, object, withObject, (.:), (.=)) import Data.Aeson.Helper (replace)+import Data.Aeson.Key (Key) import Data.Int (Int64)-import Data.Text (Text) type From = Int64 type Size = Int64@@ -73,14 +73,14 @@ ok = Ok -- | Make a JSON result to Ok-toOk :: FromJSON a => Text -> Value -> Maybe (Ok a)+toOk :: FromJSON a => Key -> Value -> Maybe (Ok a) toOk okey v = case fromJSON (replace okey "result" v) of Success v' -> Just v' _ -> Nothing -- | Make an Ok to JSON-fromOk :: ToJSON a => Text -> Ok a -> Value+fromOk :: ToJSON a => Key -> Ok a -> Value fromOk key ret = replace "result" key $ toJSON ret -- | Make list result look like '{"users": ["user1"], "total": 1, "from": 0, "size": 10}'@@ -132,12 +132,12 @@ } -- | Make a JSON to List-toList :: FromJSON a => Text -> Value -> Maybe (List a)+toList :: FromJSON a => Key -> Value -> Maybe (List a) toList okey v = case fromJSON (replace okey "result" v) of Success v' -> Just v' _ -> Nothing -- | Make a List to JSON-fromList :: ToJSON a => Text -> List a -> Value+fromList :: ToJSON a => Key -> List a -> Value fromList key ret = replace "result" key $ toJSON ret