BSD-3-Clause licensed by Patrick Nielsen
Maintained by patrick@clovyr.io

Module documentation for 1.0.5.0

This version can be pinned in stack with:aeson-yaml-1.0.5.0@sha256:5786f021c1e088d6a5aa259120ec5b1f22bb1757f4427c1a87e0513d00f17f31,1975

aeson-yaml

BSD3-licensed, pure Haskell library to encode any Aeson value as YAML.

Usage

import qualified Data.Aeson.Yaml as Aeson.Yaml

Aeson.Yaml.encode :: ToJSON a => a -> LazyByteString

-- To encode multiple values, separated by '---' (YAML documents),
-- use `encodeDocuments`.
Aeson.Yaml.encodeDocuments :: ToJSON a => [a] -> LazyByteString

-- To encode values of different types, use `toJSON` from `Data.Aeson`
-- like so:
encodeDocuments [toJSON x, toJSON y, toJSON z]

See bin/JsonToYaml.hs for a simple command-line application using this library.

Documentation

Hackage

License

BSD3

Motivation

This library does not depend on any external YAML library with C bindings, like yaml, or a restrictive license, like HsYaml (GPLv3). Note, though, that this library can only be used for encoding, not decoding.

This library also works with GHCJS and Eta.

Changes

Changelog

1.0.5.0 - 2019-11-30

Fixed

  • Encode empty objects as “{}” rather than “”

1.0.4.0 - 2019-11-06

Fixed

  • Quote date strings (e.g. “2038-01-19”)

1.0.3.0 - 2019-11-03

Fixed

  • Encode empty lists as “[]” rather than “\n -”

1.0.2.0 - 2019-10-15

Changed

  • Only quote YAML 1.2 boolean strings “true” and “false” (upper or lowercase), not “on”, “off”, “yes”, “y”, “no”, “n” (if you want to quote these strings, use encodeQuoted).

1.0.1.0 - 2019-10-15

Added

  • encodeQuoted: Encodes with all keys/strings quoted
  • encodeQuotedDocuments: Encodes documents with all keys/strings quoted

Changed

  • Simple strings (scalars) are now written unquoted.

  • Multi-line strings (with trailing newlines) are now written as literal block scalars.

1.0.0.0 - 2019-09-30

Initial version