Unmarshal Links type to 'links' annotated struct fields #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These changes add the ability to unmarshal links members to links-annotated struct fields.
The specification for links members can be found here: https://jsonapi.org/format/#document-links
Note that this does not change the existing marshaling behavior of links (the Linkable interface methods), though a fully fleshed out implementation probably should - it's awkward that now interface methods are used to marshal but struct fields for unmarshaling.
In other words, an implementation of links marshaling similar to the implementation proposed in PR 58 of the canonical google/jsonapi repository would be most appropriate to pair with these unmarshaling changes. The actual implementation that was accepted is PR 57, utilizing those Linkable/Metable interfaces.
From 57:
This is somewhat incorrect, and assumes that this package is always used in the context of a server and not a client (which appears to be the case in general for google/jsonapi). In a client, links members in responses can contain information that is vital to the functionality of the resource itself, so we add the ability to fetch that information here (and leave the weirdness of marshaling using a different mechanism for another day).
Test Output