将JSON int解码为字符串

I have this simple JSON string where I want user_id to be converted into string when doing json.Unmarshal:

{"user_id": 344, "user_name": "shiki"}

I have tried this:

type User struct {
  Id       string `json:"user_id,int"`
  Username string `json:"user_name"`
}

func main() {
  input := `{"user_id": 344, "user_name": "shiki"}`
  user := User{}
  err := json.Unmarshal([]byte(input), &user)
  if err != nil {
    panic(err)
  }

  fmt.Println(user)
}

But I just get this error:

panic: json: cannot unmarshal number into Go value of type string

Playground link: http://play.golang.org/p/mAhKYiPDt0

You can use the type Number which is an alias for string:

type User struct {
    Id       json.Number `json:"user_id,Number"`
    Username string `json:"user_name"`
}

Then you can simply convert it in any other code:

stringNumber := string(userInstance.Id)

Playground: http://play.golang.org/p/kQ84VnvpWi