pipes-aeson-0.4.1.8: Encode and decode JSON streams using Aeson and Pipes.

Safe Haskell | None
Language | Haskell98

Pipes.Aeson.Unchecked

Contents

- Encoding
- Decoding
  - Including lenghts

Description

This module exports facilities similar to those exported by the Pipes.Aeson module, except they do not restrict the `Value`s that might be encoded or decoded to be just valid top-level values. That is, not only `Object`s or `Array`s, according to to the RFC-4627 JSON standard.

Synopsis

- encode :: (Monad m, ToJSON a) => a -> Producer' ByteString m ()
- decode :: (Monad m, FromJSON a) => Parser ByteString m (Maybe (Either DecodingError a))
- decoded :: (Monad m, FromJSON a, ToJSON a) => Lens' (Producer ByteString m r) (Producer a m (Either (DecodingError, Producer ByteString m r) r))
- decodeL :: (Monad m, FromJSON a) => Parser ByteString m (Maybe (Either DecodingError (Int, a)))
- decodedL :: (Monad m, FromJSON a, ToJSON a) => Lens' (Producer ByteString m r) (Producer (Int, a) m (Either (DecodingError, Producer ByteString m r) r))

# Encoding

encode :: (Monad m, ToJSON a) => a -> Producer' ByteString m () Source #

Like `encode`, except it accepts any `ToJSON` instance, not just `Array` or `Object`.

# Decoding

decode Source #

Arguments

:: (Monad m, FromJSON a) |
=> Parser ByteString m (Maybe (Either DecodingError a)) |

Like `decode`, except it will decode any `FromJSON` instance, not just `Array` or `Object`.

decoded Source #

Arguments

:: (Monad m, FromJSON a, ToJSON a) |
=> Lens' (Producer ByteString m r) (Producer a m (Either (DecodingError, Producer ByteString m r) r)) |

Like `decoded`, except it will decode and decode any `FromJSON` and `ToJSON` instance, not just `Array` or `Object`.

## Including lenghts

decodeL Source #

Arguments

:: (Monad m, FromJSON a) |
=> Parser ByteString m (Maybe (Either DecodingError (Int, a))) |

Like `decode`, except it also returns the length of JSON input that was consumed in order to obtain the value, not including the length of whitespace between each parsed JSON input.

decodedL Source #

Arguments

:: (Monad m, FromJSON a, ToJSON a) |
=> Lens' (Producer ByteString m r) (Producer (Int, a) m (Either (DecodingError, Producer ByteString m r) r)) |

Like `decoded`, except it also tags each decoded entity with the length of JSON input that was consumed in order to obtain the value, not including the length of whitespace between each parsed JSON input.