wp-go/internal/plugins/phpserialize.go

17 lines
334 B
Go
Raw Permalink Normal View History

2023-01-31 16:58:42 +00:00
package plugins
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
}