gpt4 book ai didi

去编程语言: json marshalling

转载 作者:IT王子 更新时间:2023-10-29 02:34:24 27 4
gpt4 key购买 nike

我期望从以下代码中得到 {"a":"42","b":"78"},但它并没有这样做。

package main

import (
"encoding/json"
"fmt"
)

type S struct {
A int `json:"a,string"`
B *int `json:"b,string"`
}

func main() {
var s S
json.Unmarshal([]byte(`{"a":"42","b":"78"}`), &s)
m, _ := json.Marshal(s)
fmt.Println(string(m))
}

我做错了什么吗?

最佳答案

这是 go 语言 1.3 的一个已知问题。

参见 https://code.google.com/p/go/issues/detail?id=8587

关于去编程语言: json marshalling,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25919552/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com