Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yaml.v3 encoding support for json.Number #807

Open
mihaitodor opened this issue Dec 14, 2021 · 0 comments · Fixed by zillow/go-yaml#1 · May be fixed by #903
Open

yaml.v3 encoding support for json.Number #807

mihaitodor opened this issue Dec 14, 2021 · 0 comments · Fixed by zillow/go-yaml#1 · May be fixed by #903

Comments

@mihaitodor
Copy link

mihaitodor commented Dec 14, 2021

I noticed that #414 introduced encoding support for json.Number in yaml.v2. Is there any plan to port this feature to yaml.v3? Happy to put together a PR if that helps.

The following code:

package main

import (
	"encoding/json"
	"fmt"

	"gopkg.in/yaml.v3"
)

func main() {
	str := `{"foo": 3}`
	var res map[string]json.Number
	if err := json.Unmarshal([]byte(str), &res); err != nil {
		panic(err)
	}

	out, err := yaml.Marshal(res)
	if err != nil {
		panic(err)
	}

	fmt.Println(string(out))
}

prints foo: "3", but if I switch to yaml.v2, then it prints foo: 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant