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

Support for unmarshalling top-level links #51

Closed
mmikalsen opened this issue Feb 8, 2024 · 2 comments
Closed

Support for unmarshalling top-level links #51

mmikalsen opened this issue Feb 8, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@mmikalsen
Copy link
Contributor

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

@mmikalsen mmikalsen added the enhancement New feature or request label Feb 8, 2024
@zx8
Copy link

zx8 commented May 21, 2024

Sorely missing this as a feature! Would love to see it implemented as described in the OP.

@DQSevilla
Copy link
Contributor

Thanks for the contribution! This feature is now supported as of v0.10.0

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

No branches or pull requests

3 participants