Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
// See also http://ghodss.com/2014/the-right-way-to-handle-yaml-in-golang
//
package yaml // import "github.com/ghodss/yaml"
package yaml // import "github.com/ghodss/yaml"

import (
"bytes"
Expand Down Expand Up @@ -123,6 +123,12 @@ func YAMLToJSONStrict(y []byte) ([]byte, error) {
return yamlToJSON(y, nil, yaml.UnmarshalStrict)
}

// YAMLToJSONCustom is like YAMLToJSON but uses the passed in function to
// unmarshal from YAML to an object.
func YAMLToJSONCustom(y []byte, yamlUnmarshal func([]byte, interface{}) error) ([]byte, error) {
return yamlToJSON(y, nil, yamlUnmarshal)
}

func yamlToJSON(y []byte, jsonTarget *reflect.Value, yamlUnmarshal func([]byte, interface{}) error) ([]byte, error) {
// Convert the YAML to an object.
var yamlObj interface{}
Expand Down