标签:
正常情况: func main() { 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"}` var m map[string]interface{} json.Unmarshal([]byte(str), &m) fmt.Println(m) } ============================================================== 控制台打印: map[session_secret:6ce3910403a953006916f1fafef433c5 session_key:9mnRdL3CfpvaeMqn4g2A4f1b+olbN4iD079GhsDIumsoSy9AYZgVtDs2XO5FsHMys+AxZtyqVtQSjkSZtilJd1UAsAoNxI9esg== scope :basic expires_in:2.592e+06 r efresh_token:22.84564433384c3dffdf8c2b123b6da8de.315360000.1756090115.2605827041-6701125 access_token:21.060aaae1049e2604d0fa71d992aea516.2592000.1443322115.2605827041-6701125]
json串有换行 func main() { 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==","scope":"basic"}` var m map[string]interface{} json.Unmarshal([]byte(str), &m) fmt.Println(m) } ===================================================== 控制台打印: map[]
疑惑:json串来自第三方平台反馈 ,我手动将带有换行的json串调好格式可以解析,在撤销修改不能解析,但是在手动改好的串中手动制造换行却仍然可以解析
标签:
原文地址:http://my.oschina.net/u/1778309/blog/498571