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

Module documentation for 1.1.0.0

This version can be pinned in stack with:aeson-yaml-1.1.0.0@sha256:36cfdda776a43b0aa0e108c4632e0f007fa5c651e7294c57cbe2a508191808c4,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.1.0.0 - 2020-06-25

Changed

  • Every change to the YAML output format will now result in a bump of B in A.B.C.D to more closely follow the Haskell PVP. B will be bumped in case of small changes and bug fixes, and A if a change is expected to cause problems with common YAML 1.1 or 1.2 decoders.
  • encodeDocuments and encodeQuotedDocuments now output a leading ---

1.0.6.0 - 2020-02-27

Changed

  • Don’t quote simple strings containing spaces, e.g: hello world

  • Single-quote dates (like ‘2020-02-27’) and bools (‘true’ / ‘false’)

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