go字符串转map

package main

import (
	"encoding/json"
	"fmt"
	"reflect"
)

func main() {
	resString := `
			{
			  "access_token": "47_qIFirLMuWsDXVBWbUCRqWa8LnHku4L2oIALxb29p3j6adkk1L542LuhEHD2En9cXCRvCBUS"
        }`
	var resMap map[string]interface{}

	err := json.Unmarshal([]byte(resString), &resMap)

	if err != nil {
		fmt.Println("string转map失败", err)
	}
	
	fmt.Println("args取值", resMap["access_token"], reflect.TypeOf(resMap["access_token"]))
}    

  

posted @ 2021-07-28 17:19  程序员小艺  阅读(820)  评论(0编辑  收藏  举报