Check HTTP response content type before trying to decode it as JSON#1196
Check HTTP response content type before trying to decode it as JSON#1196IsaacG merged 2 commits intoexercism:mainfrom
Conversation
|
You should check for both this or ends with +json so that Jeremy can switch in the future to a +json type. E.g.
|
Done. I'm not familiar with that new format. Is the intend that you can put any arbitrary string there? |
|
Yes, common is making a media type in the That could be specced to always give the same format for the JSON, instead of merely the JSON syntax. We may never do this, but it's safe to include, guarantees a JSON-syntaxed response and allows us to later decide. GraphQL for example also has a specced response in their working draft of the spec. It guarantees not just JSON syntax, but also format. Similar: It's vital for HATEOAS (a way of designing HTTP APIs as described in Roy Fieldings thesis), used by some of the big ones. Resource dump with surface level information: Don't be smart and use web standards. Example of implementation of type-checked JSON requests and responses. |
No description provided.