2024-01-30 01:30:44 +08:00
|
|
|
package convutil
|
|
|
|
|
|
|
|
import (
|
|
|
|
"gopkg.in/yaml.v3"
|
|
|
|
)
|
|
|
|
|
|
|
|
type YamlConvert struct{}
|
|
|
|
|
2024-02-20 10:55:46 +08:00
|
|
|
func (YamlConvert) Enable() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-01-30 01:30:44 +08:00
|
|
|
func (YamlConvert) Encode(str string) (string, bool) {
|
|
|
|
return str, true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (YamlConvert) Decode(str string) (string, bool) {
|
|
|
|
var obj map[string]any
|
|
|
|
err := yaml.Unmarshal([]byte(str), &obj)
|
|
|
|
return str, err == nil
|
|
|
|
}
|