dqhsv0147421 2014-09-18 18:10
浏览 23
已采纳

去编程语言:json编组

I'm expecting {"a":"42","b":"78"} from the following code, but it doesn't do it.

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))
}

Am I doing something wrong?

  • 写回答

1条回答 默认 最新

  • dongshan4316 2014-09-18 18:12
    关注

    This is a known issue with 1.3 of the go language.

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?