golang Unmarshal 小问题

前端之家收集整理的这篇文章主要介绍了golang Unmarshal 小问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
正常情况:
funcmain(){

	str:=`{"expires_in":2592000,"refresh_token":"22.84564433384c3dffdf8c2b123b6da8de.315360000.1756090115.2605827041-6701125","access_token":"21.060aaae1049e2604d0fa71d992aea516.2592000.1443322115.2605827041-6701125","session_secret":"6ce3910403a953006916f1fafef433c5","session_key":"9mnRdL3CfpvaeMqn4g2A4f1b+olbN4iD079GhsDIumsoSy9AYZgVtDs2XO5FsHMys+AxZtyqVtQSjkSZtilJd1UAsAoNxI9esg==","scope":"basic"}`
	varmmap[string]interface{}
	json.Unmarshal([]byte(str),&m)
	fmt.Println(m)
}
==============================================================
控制台打印:
map[session_secret:6ce3910403a953006916f1fafef433c5session_key:9mnRdL3CfpvaeMqn4g2A4f1b+olbN4iD079GhsDIumsoSy9AYZgVtDs2XO5FsHMys+AxZtyqVtQSjkSZtilJd1UAsAoNxI9esg==
scope:basicexpires_in:2.592e+06r
efresh_token:22.84564433384c3dffdf8c2b123b6da8de.315360000.1756090115.2605827041-6701125access_token:21.060aaae1049e2604d0fa71d992aea516.2592000.1443322115.2605827041-6701125]
json串有换行

funcmain(){

	str:=`{"expires_in":2592000,"refresh_token":"22.18aba8ebd4838130f9506f35f93a3ca2.315360000.1756092980.2605827041-6701125","access_token":"21.27
4921d56f67b0a2e2bf988bd695fbe7.2592000.1443324980.2605827041-6701125","session_secret":"21376476ea4eac56c3382883796615a8","session_key":"9mnRdvXn5BQJ3
wGCnC\/UBA7DUyVivKDymYcPkNnFkrqS0n7OjAhiTGeKjAlDLSLs7h\/\/CibfnC8VZFJd+u8SZ02fpvHxlBPa7w==",&m)
	fmt.Println(m)
}

=====================================================
控制台打印:
map[]

疑惑:json串来自第三方平台反馈 ,我手动将带有换行的json串调好格式可以解析,在撤销修改不能解析,但是在手动改好的串中手动制造换行却仍然可以解析

原文链接:https://www.f2er.com/go/190239.html

猜你在找的Go相关文章