factual-api-0.3.0: A driver for the Factual API

Safe HaskellSafe-Infered

Data.Factual.Response

Contents

Description

This module exports the type which encapsulates Factual API responses. It also provides some utility function that can be used to manipulate the Aeson object which holds the data.

Synopsis

Response type

data Response Source

A response object has a status (that will be ok if the query was successful and error if the query failed), a version (which should always be 3.0) and the actual response data which is an Aeson value.

Instances

Utility functions

fromValue :: Value -> ResponseSource

This function is used by the API module to turn the Aeson value returned by the API into a Response value.

toList :: Value -> [Value]Source

This function can be used to convert an Aeson Array value into a vanilla list.

lookupNumber :: String -> Value -> DoubleSource

This function can be used to extract a Double from an Aeson Object (HashMap) value.

lookupString :: String -> Value -> StringSource

This function can be used to extract a String from an Aeson Object (HashMap) value.

lookupValue :: String -> Value -> ValueSource

This function can be used to extract any Aeson value from an Aeson Object (HashMap) value.

lookupValueSafe :: String -> Value -> Maybe ValueSource

This function can be used to safely extract any Aeson value from an Aeson Object (HashMap) value.

Aeson Value type

data Value

A JSON value represented as a Haskell value.