Skip to content

encoding/json: support unmarshaling []int as []string with ,string tag #16784

@chenjie4255

Description

@chenjie4255

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    1.7rc6
  2. What operating system and processor architecture are you using (go env)?
    mac
  3. What did you do?

I can marshal a int64 to json's string with a tag `json:",string"``, but it could not support a []int64 to json's string, I try the following code but it fail:

    type s struct {
        IDs []int64 `json:"ids,string"`
    }
    data := []byte(`{"ids":["123", "222"]}`)
    var ret s

    err := json.Unmarshal(data, &ret) // err here....
  1. What did you expect to see?

a succeeful result.

  1. What did you see instead?

a marshal error.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions