一般interface{}都要类型确定,然后根据实际情况进行处理
/*
Created by jinhan on 17-8-16.
Tip: 一般interface{}都要类型确定,然后根据实际情况进行处理
Update:
*/
package main
import (
"fmt"
"github.com/yvasiyarov/php_session_decoder/php_serialize"
)
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 {
// 观察可以看出interface的类型是:
//php_serialize.PhpArray{"name":"tom", "age":"23", "friends":php_serialize.PhpArray{0:php_serialize.PhpArray{