Skip to content

Support for unmarshalling top-level links #51

Closed
@mmikalsen

Description

@mmikalsen

Is your feature request related to a problem? Please describe.
The package does not support unmarshalling top-level links, usually utilizes for pagination.

Describe the solution you'd like
UnmarshalOption to export the links from top-level, which has been done with meta. for example:

body := `{"data":{"id":"1","type":"articles","attributes":{"title":"Hello World"}},"links":{"self":"foobar"}}`

type Article struct {
    ID    string `jsonapi:"primary,articles"`
    Title string `jsonapi:"attribute"        json:"title"`
}

var (
    a Article
    l jsonapi.Link
)

err := jsonapi.Unmarshal([]byte(body), &a, jsonapi.UnmarshalLinks(&l))
// l.self = "foobar"

Describe alternatives you've considered
n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions