golang json解析{"code":200,"data":{"seqId":"0a0cc7b25d3d4fa2bd9500e3398ed056","telX":"13146538214"}}并获取seqId的值
时间: 2023-11-05 08:06:08 浏览: 93
可以使用以下代码来解析JSON并获取seqId的值:
```
package main
import (
"encoding/json"
"fmt"
)
func main() {
jsonData := []byte(`{"code":200,"data":{"seqId":"0a0cc7b25d3d4fa2bd9500e3398ed056","telX":"13146538214"}}`)
var result map[string]interface{}
err := json.Unmarshal(jsonData, &result)
if err != nil {
fmt.Println(err)
return
}
data := result["data"].(map[string]interface{})
seqId := data["seqId"].(string)
fmt.Println(seqId)
}
```
输出结果为:0a0cc7b25d3d4fa2bd9500e3398ed056。
--相关问题--:
1. 如何在Golang中将结构体转换为JSON字符串?
2. 如何在Golang中处理JSON数组?
3.
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![.zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)