aeson-1.2.0.0: Fast JSON parsing and encoding

Safe HaskellNone
LanguageHaskell2010

Data.Aeson.Encoding

Contents

Description

Functions in this module return well-formed Encoding'. Polymorphic variants, which return Encoding a, return a textual JSON value, so it can be used as both Encoding' Text and Encoding = Encoding' Value.

Synopsis

Encoding

type Encoding = Encoding' Value Source #

Often used synonnym for Encoding'.

data Encoding' tag Source #

An encoding of a JSON value.

tag represents which kind of JSON the Encoding is encoding to, we reuse Text and Value as tags here.

Instances

fromEncoding :: Encoding' tag -> Builder Source #

Acquire the underlying bytestring builder.

unsafeToEncoding :: Builder -> Encoding' a Source #

Make Encoding from Builder.

Use with care! You have to make sure that the passed Builder is a valid JSON Encoding!

data Series Source #

A series of values that, when encoded, should be separated by commas. Since 0.11.0.0, the .= operator is overloaded to create either (Text, Value) or Series. You can use Series when encoding directly to a bytestring builder as in the following example:

toEncoding (Person name age) = pairs ("name" .= name <> "age" .= age)

pairs :: Series -> Encoding Source #

Encode a series of key/value pairs, separated by commas.

Predicates

Encoding constructors

list :: (a -> Encoding) -> [a] -> Encoding Source #

dict Source #

Arguments

:: (k -> Encoding' Text)

key encoding

-> (v -> Encoding)

value encoding

-> (forall a. (k -> v -> a -> a) -> a -> m -> a)

foldrWithKey - indexed fold

-> m

container

-> Encoding 

Encode as JSON object

Decimal numbers

Decimal numbers as Text

Time

value