jsonapi
jsonapi copied to clipboard
Support Unmarshaling of Errors
Is your feature request related to a problem? Please describe. Currently our lib does not support Unmarshaling errors because it is not seen in requests to JSON:API servers, but it would be a nice-to-have feature for testing / consuming responses from JSON:API-servers.
Describe the solution you'd like
Unmarshal works for jsonapi.Error
Describe alternatives you've considered N/A
Additional context There are other things that this lib does not Unmarshal, like links or relationship metas, that may be interesting to do as well
This would be nice to have, as a workaround I am doing the following:
import (
"encoding/json"
"github.com/DataDog/jsonapi"
)
// ...
// https://github.com/DataDog/jsonapi/issues/36
type jsonAPIDocumentWithErrors struct {
Errors []*jsonapi.Error `json:"errors"`
}
// ....
var errorDoc jsonAPIDocumentWithErrors
_ = json.Unmarshal(bytes, &errorDoc)
// check errorDoc.Errors