php_serializeinterface{}interface{}
2.示例代码:
package main
import (
"github.com/yvasiyarov/php_session_decoder/php_serialize"
"fmt"
)
func main() {
str := `a:3:{s:4:"name";s:3:"tom";s:3:"age";s:2:"23";s:7:"friends";a:2:{i:0;a:1:{s:4:"name";s:5:"jerry";}i:1;a:1:{s:4:"name";s:4:"jack";}}}`
decoder := php_serialize.NewUnSerializer(str)
if result, err := decoder.Decode(); err != nil {
panic(err)
} else {
fmt.Println(result)
}
}
打印结果:
map[name:tom age:23 friends:map[0:map[name:jerry] 1:map[name:jack]]]
resultphp_serialize.PhpValuePhpValueinterface{}
resultnameagefriends