Content deleted Content added
→top: misleading - it is an (old) draft |
m v2.05b - Bot T20 CW#61 - Fix errors for CW project (Reference before punctuation) |
||
(48 intermediate revisions by 41 users not shown) | |||
Line 1:
{{Short description|Proposed computer definition standard}}
'''Hypertext Application Language''' ('''HAL''') is
HAL was created to be simple to use and easily applicable across different [[___domain (software engineering)|domains]] by avoiding the need to impose any requirements on how the project be structured.
▲'''Hypertext Application Language''' ('''HAL''') is an [[Internet Draft]] (a "work in progress") standard convention for defining hypermedia such as links to external resources within [[JSON]] or [[XML]] code. The standard was initially proposed on June 2012 specifically for use with JSON<ref name="rfc4627">{{cite journal|title=JSON Hypertext Application Language|journal=Network Working Group|date=6-7-2012|issue=Internet-Draft|url=http://tools.ietf.org/pdf/rfc4627.pdf|format=PDF|accessdate=23 July 2014}}</ref> and has since become available in two variations, each specific to JSON or XML. The two associated [[MIME]] types are media type: application/hal+xml and media type: application/hal+json.<ref>{{cite book|last1=Richardson|first1=Leonard|last2=Ruby|first2=Mike Amundsen ; foreword by Sam|title=RESTful Web APIs|date=2013|publisher=O'Reilly|___location=Sebastopol, CA|isbn=978-1-4493-5806-8|edition=First edition.|accessdate=23 July 2014|chapter=7}}</ref>
APIs that adopt HAL
▲HAL was created to be simple to use and easily applicable across different domains by avoiding the need to impose any requirements on how the project be structured. Maintaining this minimal impact approach, HAL has enabled developers to create general-purpose libraries which can be easily incorporated on any [[API]] that uses HAL.<ref name="rfc4627"/>
▲APIs that adopt HAL are generally more appealing to developers{{pov inline|date=March 2015}} because it simplifies the use of open source libraries and makes it possible to interact with the API using JSON or XML. The alternative would be having to develop a proprietary format which in turn forces developers to learn how to use yet another foreign format.<ref name="stateless">{{cite web|last1=Kelly|first1=Mike|title=HAL - Hypertext Application Language A lean hypermedia type|url=http://stateless.co/hal_specification.html|accessdate=23 July 2014|date=2011-06-13}}</ref>
== Convention ==
HAL is structured in such a way as to represent elements based on two concepts:
==Example==
General Resource
<syntaxhighlight lang="json">
{
"_links": {
"self": {
"href": "http://example.com/api/book/hal-cookbook"
}
},
"id": "hal-cookbook",
"name": "HAL Cookbook"
}
</syntaxhighlight>
Embedded resource
<syntaxhighlight lang="json">
{
"_links": {
"self": {
"href": "http://example.com/api/book/hal-cookbook"
}
},
"_embedded": {
"author": {
"_links": {
"self": {
"href": "http://example.com/api/author/shahadat"
}
},
"id": "shahadat",
"name": "Shahadat Hossain Khan",
"homepage": "http://author-example.com"
}
},
"id": "hal-cookbook",
"name": "HAL Cookbook"
}
</syntaxhighlight>
Collections
<syntaxhighlight lang="json">
{
"_links": {
"self": {
"href": "http://example.com/api/book/hal-cookbook"
},
"next": {
"href": "http://example.com/api/book/hal-case-study"
},
"prev": {
"href": "http://example.com/api/book/json-and-beyond"
},
"first": {
"href": "http://example.com/api/book/catalog"
},
"last": {
"href": "http://example.com/api/book/upcoming-books"
}
},
"_embedded": {
"author": {
"_links": {
"self": {
"href": "http://example.com/api/author/shahadat"
}
},
"id": "shahadat",
"name": "Shahadat Hossain Khan",
"homepage": "http://author-example.com"
}
},
"id": "hal-cookbook",
"name": "HAL Cookbook"
}
</syntaxhighlight>
==See also==
* [[HATEOAS]]
* [[CURIE]], (or Compact [[URI]])
== References ==
Line 17 ⟶ 91:
==External links==
* [https://tools.ietf.org/html/draft-kelly-json-hal-
[[Category:JSON]]
Line 27 ⟶ 99:
[[Category:XML-based standards]]
[[Category:World Wide Web Consortium standards]]
|