clovyr / aeson-yaml

Encode any Aeson (JSON) value as YAML (in pure Haskell)
https://hackage.haskell.org/package/aeson-yaml
BSD 3-Clause "New" or "Revised" License
12 stars 7 forks source link

YAML strings containing a colon followed by a space should be quoted #12

Open paulrbr-fl opened 3 years ago

paulrbr-fl commented 3 years ago

Hello this bug report was originally posted in https://github.com/dhall-lang/dhall-haskell/issues/1939#issuecomment-674149478 byt the incorrect configuration (with dhall-to-yaml --version v1.7.1) seem to be because of a change in aeson-yaml (which removed the comment warning about the : string sequence. See the bug in action:

> dhall-to-yaml --version
1.7.1

> dhall version
1.34.0

> dhall-to-yaml <<< '{ headers = ["Location: https://example.com"] }'
headers:
  - Location: https://example.com

> dhall <<< '{ headers = ["Location: https://example.com"] }'
{ headers = [ "Location: https://example.com" ] }

The YAML generated value is a Hash containing a List containing… another Hash! Whereas the normalised form output from dhall is (correctly 😌) a Hash containing a List containing a String.

sjakobi commented 3 years ago

Here's another instance (from https://github.com/dhall-lang/dhall-haskell/issues/2192):

$ echo '{"b":"c:","a":["v:"]}' | json-to-yaml 
a:
  - v:
b: c: