curl-aeson 0.0.3 → 0.0.4
raw patch · 2 files changed
+8/−8 lines, 2 filesdep +utf8-stringdep −bytestringPVP ok
version bump matches the API change (PVP)
Dependencies added: utf8-string
Dependencies removed: bytestring
API changes (from Hackage documentation)
Files
- curl-aeson.cabal +3/−3
- src/Network/Curl/Aeson.hs +5/−5
curl-aeson.cabal view
@@ -1,5 +1,5 @@ name: curl-aeson-version: 0.0.3+version: 0.0.4 synopsis: Communicate with HTTP service using JSON description: A library for communicating with JSON over HTTP connection. Supports rich set of HTTP connectivity features provided by@@ -29,9 +29,9 @@ build-depends: aeson >= 0.6.0.0, base >= 4 && < 5,- bytestring, curl >= 1.3.7,- text+ text,+ utf8-string >= 0.3 source-repository head type: git
src/Network/Curl/Aeson.hs view
@@ -31,7 +31,7 @@ import Control.Monad import Data.Aeson import Data.Aeson.Types-import Data.ByteString.Lazy.Char8 (pack,unpack)+import Data.ByteString.Lazy.UTF8 (fromString,toString) import Data.Maybe import Data.Text (Text) import Data.Typeable@@ -52,7 +52,7 @@ -- The request automatically has @Content-type: application/json@ -- header if you pass any data. This function is lenient on response -- content type: everything is accepted as long as it is parseable--- with 'decode'.+-- with 'decode'. HTTP payload is expected to be UTF-8 encoded. -- -- If you need authentication, you need to pass session cookie or -- other means of authentication tokens via 'CurlOption' list.@@ -72,7 +72,7 @@ curlAeson parser method url extraOpts maybeContent = do (curlCode,received) <- curlGetString url curlOpts when (curlCode /= CurlOK) $ throw CurlAesonException{errorMsg="HTTP error",..}- let ast = case decode $ pack received of+ let ast = case decode $ fromString received of Nothing -> throw CurlAesonException{errorMsg="JSON parsing failed",..} Just x -> x return $ case parseEither parser ast of@@ -83,7 +83,7 @@ commonOpts = [CurlCustomRequest method] dataOpts = case maybeContent of Nothing -> []- Just a -> [CurlPostFields [unpack $ encode a]+ Just a -> [CurlPostFields [toString $ encode a] ,CurlHttpHeaders ["Content-type: application/json"] ] @@ -116,7 +116,7 @@ -- | Useful for just giving the JSON as string when it is static -- anyway and doesn't need to be programmatically crafted. rawJson :: String -> Maybe Value-rawJson = decode . pack+rawJson = decode . fromString -- |To avoid ambiguity in type checker you may pass this value instead -- of Nothing to 'curlAeson'.