aeson-0.10.0.0: Fast JSON parsing and encoding

Copyright | (c) 2012-2015 Bryan O'Sullivan (c) 2011 MailRank, Inc.
License | Apache
Maintainer | Bryan O'Sullivan <bos@serpentine.com>
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell98

Data.Aeson.Encode

Contents

- Encoding to Builders
- Deprecated

Description

Efficiently serialize a JSON value.

Most frequently, you'll probably want to encode straight to UTF-8 (the standard JSON encoding) using `encode`.

You can use the conversions to `Builder`s when embedding JSON messages as parts of a protocol.

Synopsis

- encode :: ToJSON a => a -> ByteString
- encodeToBuilder :: Value -> Builder
- encodeToTextBuilder :: Value -> Builder
- fromValue :: Value -> Builder

# Documentation

encode :: ToJSON a => a -> ByteString Source

Efficiently serialize a JSON value as a lazy `ByteString`.

This is implemented in terms of the `ToJSON` class's `toEncoding` method.

# Encoding to Builders

encodeToBuilder :: Value -> Builder Source

Encode a JSON value to a Data.ByteString `Builder`.

Use this function if you are encoding over the wire, or need to prepend or append further bytes to the encoded JSON value.

encodeToTextBuilder :: Value -> Builder Source

Encode a JSON `Value` to a Data.Text `Builder`, which can be embedded efficiently in a text-based protocol.

If you are going to immediately encode straight to a `ByteString`, it is more efficient to use `encodeToBuilder` instead.

# Deprecated

fromValue :: Value -> Builder Source

Deprecated: Use `encodeToTextBuilder` instead