goccy / go-yaml

YAML support for the Go language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Library cannot unmarshal its own YAML

malcolmholmes opened this issue · comments

Describe the bug
I have been using the library to write out (and then parse) Grafana dashboards. Turns out Grafana dashboards can do some horrendous things in their JSON representation. Some of these confuse this library.

There are three principal issues I've found, all to do with escaped characters in keys, which are allowed in JSON, and are also allowed in YAML (even if, I admit, a very bad idea).

The three are:

  • Newlines in keys
  • Backslashes in keys
  • Double quotes in keys

To Reproduce

Please provide a minimum yaml content that can be reproduced.

https://go.dev/play/p/F3gi3Jp4HMK

Expected behavior
The YAML/map[string]any snippets in the above code should parse without error.

Version Variables

  • Go version: 1.21.4
  • go-yaml's Version: v1.11.2 / master

I'm happy to help debug and resolve this - the Grizzly needs a decent YAML parser that can handle whatever Grafana throws at it.

I see the go.dev link already doesn't work, bah. I converted the main.go file into proper unit tests and created a PR in #418.