Files
go-easy-utils/jsonUtil/json_to_struct_slice_test.go
jeffery bbe169cba0 fix:parse slices (#37)
1. Does not support parsing map type
2. Parse the slice type, if the data type is inconsistent, panic error

close #35
2023-05-11 17:41:34 +08:00

25 lines
338 B
Go

package jsonUtil
import (
"testing"
)
func TestJsonToStructSlice1(t *testing.T) {
data := `
{
"uid": 43015653,
"fids": ["43015653", 43015666]
}
`
var target struct {
Uid int `json:"uid"`
Fids []string `json:"fids"`
}
err := JsonToStruct(data, &target)
if err != nil {
t.Errorf("err %s", err)
return
}
}