wp-go/internal/phphelper/unserialize.go
2023-02-14 19:47:47 +08:00

17 lines
336 B
Go

package phphelper
import (
"github.com/elliotchance/phpserialize"
"github.com/fthvgb1/wp-go/helper/maps"
)
func UnPHPSerialize[T any](s string) (r T, err error) {
var rr map[any]any
err = phpserialize.Unmarshal([]byte(s), &rr)
if err == nil {
rx := maps.AnyAnyToStrAny(rr)
r, err = maps.StrAnyMapToStruct[T](rx)
}
return
}