mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
change third party package for yaml parsing to gopkg.in/yaml.v3
This commit is contained in:
@ -9,8 +9,8 @@ package gyaml
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/gf-third/yaml"
|
||||
"github.com/gogf/gf/util/gconv"
|
||||
)
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user