change third party package for yaml parsing to gopkg.in/yaml.v3

This commit is contained in:
John
2020-04-03 19:51:33 +08:00
parent f22b98456f
commit ccceeae29c
4 changed files with 35 additions and 17 deletions

View File

@ -9,8 +9,8 @@ package gyaml
import (
"encoding/json"
"gopkg.in/yaml.v3"
"github.com/gf-third/yaml"
"github.com/gogf/gf/util/gconv"
)

View File

@ -3,9 +3,11 @@
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
package gyaml_test
import (
"encoding/json"
"testing"
"github.com/gogf/gf/encoding/gparser"
@ -81,6 +83,20 @@ func Test_DecodeError(t *testing.T) {
})
}
func Test_DecodeMapToJson(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
data := []byte(`
m:
k: v
`)
v, err := gyaml.Decode(data)
t.Assert(err, nil)
b, err := json.Marshal(v)
t.Assert(err, nil)
t.Assert(b, `{"m":{"k":"v"}}`)
})
}
func Test_ToJson(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
m := make(map[string]string)