golang实现php里的serialize()和unserialize()序列和反序列办法
发布时间:05/20 来源:未知 浏览:
关键词:
Golang 实现 PHP里的 serialize() 、 unserialize()
安装
go get -u github.com/techleeone/gophp/serialize
用法
package main import ( "fmt" "github.com/techleeone/gophp/serialize" ) func main() { str := `a:1:{s:3:"php";s:24:"世界上最好的说话";}` // unserialize() in php out, _ := serialize.UnMarshal([]byte(str)) fmt.Println(out) //map[php:世界上最好的说话] // serialize() in php jsonbyte, _ := serialize.Marshal(out) fmt.Println(string(jsonbyte)) // a:1:{s:3:"php";s:24:"世界上最好的说话";} }
github地址: https://github.com/techleeone...