feat: 增加map类型转换

This commit is contained in:
2025-10-13 12:52:01 +08:00
parent 059830d87d
commit 2100caa5e4
5 changed files with 73 additions and 2 deletions

30
op_string/map_test.go Normal file
View File

@ -0,0 +1,30 @@
// Package op_string ...
//
// Description : op_string ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2025-10-13 12:21
package op_string
import (
"testing"
"encoding/json"
. "github.com/smartystreets/goconvey/convey"
)
func TestToMap(t *testing.T) {
Convey("map[string]any转换成", t, func() {
testData := `{
"name": "baicha",
"age": 18
}`
res := ToMap[string, any](testData)
So(res.Err, ShouldBeNil)
So(res.Value, ShouldNotBeNil)
So(res.Value["name"], ShouldEqual, "baicha")
So(res.Value["age"], ShouldEqual, json.Number("18"))
})
}