Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
chenjie4255 opened this issue Aug 18, 2016 · 1 comment
Closed

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

chenjie4255 opened this issue Aug 18, 2016 · 1 comment

Comments

@chenjie4255
Copy link

@chenjie4255 chenjie4255 commented Aug 18, 2016

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.

@odeke-em odeke-em changed the title support json marshal from []int to array of string encoding/json: support unmarshaling []int as []string with ,string tag Aug 18, 2016
@odeke-em

This comment has been minimized.

Copy link
Member

@odeke-em odeke-em commented Aug 18, 2016

Duplicate of #15624, which has been marked as a feature request. Closing in favor of the mentioned issue.

@odeke-em odeke-em closed this Aug 18, 2016
@golang golang locked and limited conversation to collaborators Aug 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.