问题
Given an API that returns a set of HTTP links, what JSON format or formats should be used to represent the resource?
RFC6690 describes application/link-format
for a collection of links.
What JSON format or formats are appropriate for representing a collection of links as JSON instead?
Obviously we could invent one but it would be better to adopt a standard or de-facto standard.
I have come across several competing/overlapping standards including (in order of my perception of their popularity):
- HAL+JSON and
- JSON-LD
- Collection+JSON
- OData
How popular are these compared to each other and application/link-format
?
Does anyone routinely use application/link-format
(link headers are of course very common)?
There are some blog entries on the subject:
- https://www.mnot.net/blog/2011/11/25/linking_in_json
- https://sookocheff.com/post/api/on-choosing-a-hypermedia-format/
- https://evertpot.com/json-links/
and a few relevant SO questions:
- What is the best practice for referencing JSON Schema for your state representations in REST?
- Link headers vs link elements for RESTful JSON
来源:https://stackoverflow.com/questions/59270469/what-is-the-best-json-schema-to-use-for-a-collection-of-http-links