猿问

Golang中的严格json解析器

在Go中,我有一些来自第三方API的JSON,然后尝试解析它:


b := []byte(`{"age":21,"married":true}`)

var response_hash map[string]string

_ = json.Unmarshal(b, &response_hash)

但它失败(response_hash变为空),并且Unmarshal只能处理带引号的JSON:


b := []byte(`{"age":"21","married":"true"}`)

var response_hash map[string]string

_ = json.Unmarshal(b, &response_hash)

有什么方法可以从第三方API读取JSON的第一个版本?


牧羊人nacy
浏览 222回答 1
1回答
随时随地看视频慕课网APP

相关分类

Go
我要回答