-
Notifications
You must be signed in to change notification settings - Fork 215
Is it possible to Unmarshal into a map? #53
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
Comments
Unfortunately an Library support aside, I think in your specific case you may want to consider each type Player struct {
ID int `jsonapi:"primary,players"`
Path string `jsonapi:"attr,path"`
Files *File `jsonapi:"relation,files"`
}
type File struct {
Name string `jsonapi:"primary,files"`
Path string `jsonapi:"attr,path"`
isDir bool `jsonapi:"attr,isDir"`
time time.Time `jsonapi:"attr,time"`
} |
Thanks for the response, I do agree in principle that the schema is.. confused however this is a bit of a legacy api and changes can't be made easily. I will investigate adding nested attribute support to the library. |
@aren55555 @nodefortytwo does the jsonapi spec permit such attribute configuration? |
@shwoodard yes the JSON API spec does permit this configuration; take a look at http://jsonapi.org/format/#document-resource-object-attributes:
|
@nodefortytwo in looking at this again I also noticed all the keys in your sample JSON payload are not strings; ie That payload will cause an error outside of the JSON API library; it will fail the vanilla go JSON unmarshal. |
I should also mention that I have been working on a JSON API payload validator... its a WIP so it's not yet perfect, but it will catch anything really obvious/easy to implement: http://corroborate.arenpatel.com/
That payload shows results in no errors/warnings. |
Sorry just got the notification about this. the data vs "data" thing was caused by copying from JSON View :) JSON validator is cool, I generally use pro.jsonlint.com |
I can't seem to get this to work:
The text was updated successfully, but these errors were encountered: