beta版本的ToStructBeta正式升级为 ToStruct (#109)

This commit is contained in:
jefferyjob
2025-08-16 20:52:20 +08:00
committed by GitHub
parent c2cd2b2c81
commit 627648d9a2
6 changed files with 5 additions and 5 deletions

View File

@@ -6,8 +6,8 @@ import (
"reflect"
)
// ToStructBeta JSON转结构体
func ToStructBeta(jsonStr string, target any) error {
// ToStruct JSON转结构体
func ToStruct(jsonStr string, target any) error {
// 将 JSON 解成 map[string]any
var raw map[string]any
if err := json.Unmarshal([]byte(jsonStr), &raw); err != nil {

View File

@@ -83,7 +83,7 @@ type Address struct {
func TestToStruct1Beta(t *testing.T) {
s := &S1{}
err := ToStructBeta(Json1, s)
err := ToStruct(Json1, s)
require.NoError(t, err)
fmt.Printf("%+v\n", s)

View File

@@ -20,7 +20,7 @@ type tmS1 struct {
func TestMap1Beta(t *testing.T) {
var s tmS1
err := ToStructBeta(tmJ1, &s)
err := ToStruct(tmJ1, &s)
require.NoError(t, err)
fmt.Printf("%+v\n", s)

View File

@@ -20,7 +20,7 @@ type tsS1 struct {
func TestStruct1Beta(t *testing.T) {
var s tsS1
err := ToStructBeta(tsJ1, &s)
err := ToStruct(tsJ1, &s)
require.NoError(t, err)
fmt.Printf("%+v\n", s)