Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.
This repository was archived by the owner on Sep 4, 2025. It is now read-only.

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

Open

Description

@darwinyip

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'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions