You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My apologies if this is addressed elsewhere, but I've looked through the example code, and all past issues and PRs, and haven't found an answer to my question.
I gather that through the use of a Wrapper, it ought to be possible to unmarshal a JSON:API document into a Go struct, but how?
The unmarshal_document_test.go example uses a struct type (User{} and Article{}) to define the schema, but then when printing the result, it uses res.Get, rather than accessing an instance of the *User and/or *Article types.
Is this possible? If so, how?
Thanks.
The text was updated successfully, but these errors were encountered:
I don't think it's currently possible to do what you are asking here, but it probably should.
Originally, you'd use the struct to build a Type and provide it to the Schema. Since then, a feature was added to create new instances from a Type (NewFunc field).
Using that feature, I can think of a method called ToStruct (just an example) that would create a new object using whatever was used to build the type, then populate it with the correct attributes and relationships, then return that.
My apologies if this is addressed elsewhere, but I've looked through the example code, and all past issues and PRs, and haven't found an answer to my question.
I gather that through the use of a Wrapper, it ought to be possible to unmarshal a JSON:API document into a Go struct, but how?
The
unmarshal_document_test.go
example uses a struct type (User{}
andArticle{}
) to define the schema, but then when printing the result, it usesres.Get
, rather than accessing an instance of the*User
and/or*Article
types.Is this possible? If so, how?
Thanks.
The text was updated successfully, but these errors were encountered: