influxdb-1.9.2: InfluxDB client library for Haskell
Safe HaskellNone
LanguageHaskell2010

Database.InfluxDB.JSON

Synopsis

Result parsers

parseResultsWith Source #

Arguments

:: (Maybe Text -> HashMap Text Text -> Vector Text -> Array -> Parser a)

A parser that parses a measurement. A measurement consists of

  1. an optional name of the series
  2. a map of tags
  3. an array of field keys
  4. an array of field values
-> Value

JSON response

-> Parser (Vector a) 

Parse a JSON response with the strictDecoder.

parseResultsWithDecoder Source #

Arguments

:: Decoder 
-> (Maybe Text -> HashMap Text Text -> Vector Text -> Array -> Parser a)

A parser that parses a measurement. A measurement consists of

  1. an optional name of the series
  2. a map of tags
  3. an array of field keys
  4. an array of field values
-> Value

JSON response

-> Parser (Vector a) 

Parse a JSON response with the specified decoder settings.

Decoder settings

newtype Decoder Source #

A decoder to use when parsing a JSON response.

Use strictDecoder if you want to fail the entire decoding process if there's any failure. Use lenientDecoder if you want the decoding process to collect only successful results.

Constructors

Decoder (forall a. SomeDecoder a) 

data SomeDecoder a Source #

SomeDecoder a represents how to decode a JSON response given a row parser of type Parser a.

Constructors

forall b. SomeDecoder 

Fields

strictDecoder :: Decoder Source #

A decoder that fails immediately if there's any parse failure.

strictDecoder is defined as follows:

strictDecoder :: Decoder
strictDecoder = Decoder $ SomeDecoder
 { decodeEach = id
 , decodeFold = id
 }

lenientDecoder :: Decoder Source #

A decoder that ignores parse failures and returns only successful results.

Getting fields and tags

getField Source #

Arguments

:: MonadFail m 
=> Text

Column name

-> Vector Text

Columns

-> Vector Value

Field values

-> m Value 

Get a field value from a column name

getTag Source #

Arguments

:: MonadFail m 
=> Text

Tag name

-> HashMap Text Value

Tags

-> m Value 

Get a tag value from a tag name

Common JSON object parsers

parseUTCTime :: Precision ty -> Value -> Parser UTCTime Source #

Parse either a POSIX timestamp or RFC3339 formatted timestamp as UTCTime.

parsePOSIXTime :: Precision ty -> Value -> Parser POSIXTime Source #

Parse either a POSIX timestamp or RFC3339 formatted timestamp as POSIXTime.

parseRFC3339 :: ParseTime time => Value -> Parser time Source #

Parse a RFC3339-formatted timestamp.

Note that this parser is slow as it converts a Text input to a String before parsing.

Utility functions

parseResultsObject :: Value -> Parser (Vector Value) Source #

Parse a result response.

parseSeriesObject :: Value -> Parser (Vector Value) Source #

Parse a series response.

parseSeriesBody :: Value -> Parser (Maybe Text, HashMap Text Text, Vector Text, Array) Source #

Parse the common JSON structure used in query responses.

parseErrorObject :: Value -> Parser String Source #

Parse the common JSON structure used in failure response.