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

Can't UnMarshal into struct with json.RawMessage type #142

Open
darwinyip opened this issue Jun 7, 2018 · 0 comments
Open

Can't UnMarshal into struct with json.RawMessage type #142

darwinyip opened this issue Jun 7, 2018 · 0 comments

Comments

@darwinyip
Copy link

I can't seem to be able to do the following:

var data = []byte(`{
  "data": {
    "attributes": {
      "values": ["abc"]
    },
    "type": "things"
  }
}`)

type Thing struct {
	ID string `jsonapi:"primary,things"`
	Values json.RawMessage `jsonapi:"attr,values"`
}

var thing Thing
r := bytes.NewReader(data)
if err := jsonapi.UnmarshalPayload(r, &thing); err != nil {
	panic(err)
}

I get panic: data is not a jsonapi representation of '*main.Thing'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant