aeson-yaml

Output any Aeson value as YAML (pure Haskell library)

https://github.com/clovyr/aeson-yaml

Version on this page:1.0.6.0@rev:1
LTS Haskell 22.39:1.1.0.1@rev:4
Stackage Nightly 2024-10-31:1.1.0.1@rev:4
Latest on Hackage:1.1.0.1@rev:4

See all snapshots aeson-yaml appears in

BSD-3-Clause licensed by Patrick Nielsen
Maintained by [email protected]
This version can be pinned in stack with:aeson-yaml-1.0.6.0@sha256:bfca81925cf541462e1400ff99629f81836755bc82bac20a6289c5ef0cd83ccc,2072

Module documentation for 1.0.6.0

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.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