packages feed

curl-aeson 0.1.0.0 → 0.1.0.1

raw patch · 2 files changed

+26/−17 lines, 2 files

Files

README.md view
@@ -16,24 +16,30 @@  ## Example -In this example we fetch latest bid and ask values from a Bitcoin-exchange using-[their public API](https://github.com/paytunia/api-documentation#read-the-ticker):+Let's simulate a ticker service by creating a file `/tmp/ticker.json`+with the following content: +```json+{"bid":3,"ask":3.14}+```++We then define our own data type and define a function which reads the+payload from the service:+ ```haskell-{-# LANGUAGE OverloadedStrings #-}-import Control.Monad+{-# LANGUAGE DeriveGeneric #-}+import GHC.Generics import Data.Aeson import Network.Curl.Aeson -ticker :: IO (Double,Double)-ticker = curlAesonGetWith p "https://bitcoin-central.net/api/v1/ticker/eur"-  where-    p (Object o) = do-      bid <- o .: "bid"-      ask <- o .: "ask"-      return (bid,ask)-    p _ = mzero+data Ticker = Ticker { bid :: Double+                     , ask :: Double+                     } deriving (Generic, Show)++instance FromJSON Ticker++ticker :: IO Ticker+ticker = curlAesonGet "file:///tmp/ticker.json" ```  You may find more examples from package documentation.
curl-aeson.cabal view
@@ -1,9 +1,12 @@ cabal-version:       >=1.10 name:                curl-aeson-version:             0.1.0.0-synopsis:            Communicate with HTTP service using JSON -description:         A library for communicating with JSON over HTTP-                     connection. Supports rich set of HTTP connectivity+version:             0.1.0.1+synopsis:            Communicate with web services using JSON +description:         A library for communicating with JSON over HTTP(S)+                     or any other protocols supported by cURL.+                     connection.+                     .+                     Supports rich set of connectivity                      features provided by libcurl combined to the                      performance and elegancy of aeson.                      .