Hypertext Application Language: Difference between revisions

Content deleted Content added
No edit summary
m Example: <source lang="json">
Line 7:
== Convention ==
HAL is structured in such a way as to represent elements based on two concepts: Resources and Links. Resources consist of [[URI]] links, embedded resources, your standard data (be it JSON or XML), and non URI links. Links have a target URI, as well as the name of the link (referred to as 'rel'), as well as optional properties designed to be mindful of deprecation and content negotiation.<ref name="stateless"/>
 
 
==Example==
General Resource
<source lang="json">
<pre>
{
"_links": {
Line 20 ⟶ 21:
"name": "HAL Cookbook"
}
</presource>
Embedded resource
<source lang="json">
<pre>
{
"_links": {
Line 43 ⟶ 44:
"name": "HAL Cookbook"
}
</presource>
Collections
<source lang="json">
<pre>
{
"_links": {
"self": {
"href": "<nowiki>http://example.com/api/book/hal-cookbook</nowiki>"
},
"next": {
"href": "<nowiki>http://example.com/api/book/hal-case-study</nowiki>"
},
"prev": {
"href": "<nowiki>http://example.com/api/book/json-and-beyond</nowiki>"
},
"first": {
"href": "<nowiki>http://example.com/api/book/catalog</nowiki>"
},
"last": {
"href": "<nowiki>http://example.com/api/book/upcoming-books</nowiki>"
}
},
Line 68 ⟶ 69:
"_links": {
"self": {
"href": "<nowiki>http://author-example.com</nowiki>"
}
},
Line 78 ⟶ 79:
"name": "HAL Cookbook"
}
</presource>
 
==See also==
* [[HATEOAS]]