请输入您要查询的百科知识:

 

词条 Hypertext Application Language
释义

  1. Convention

  2. Example

  3. See also

  4. References

  5. External links

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[1] and has since become available in two variations, JSON and XML. The two associated MIME types are media type: application/hal+xml and media type: application/hal+json.[2]

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.{{Citation needed|Reason=RFC4627 does not mention HAL|date=October 2018}}

APIs that adopt HAL simplify the use of open source libraries and make 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.[3]

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.[3]

Example

General Resource

{
  "_links": {    "self": {      "href": "http://example.com/api/book/hal-cookbook"    }  },  "id": "hal-cookbook",  "name": "HAL Cookbook"

}

Embedded resource

{
  "_links": {    "self": {      "href": "http://example.com/api/book/hal-cookbook"    }  },  "_embedded": {    "author": {      "_links": {        "self": {          "href": "http://author-example.com"        }      },       "id": "shahadat",      "name": "Shahadat Hossain Khan"    }  },  "id": "hal-cookbook",  "name": "HAL Cookbook"

}

Collections

{
  "_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://author-example.com"        }      },      "id": "shahadat",      "name": "Shahadat Hossain Khan"    }  },  "id": "hal-cookbook",  "name": "HAL Cookbook"

}

See also

  • HATEOAS
  • CURIE, (or Compact URI)

References

1. ^{{cite web |last1=Kelly |first1=Mike |title=JSON Hypertext Application Language |url=https://tools.ietf.org/html/draft-kelly-json-hal-00 |publisher=IETF |accessdate=16 October 2018 |date=7 June 2012}}
2. ^{{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|chapter=7}}
3. ^{{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}}

External links

  • [https://tools.ietf.org/html/draft-kelly-json-hal-08 JSON Hypertext Application Language latest draft]
{{Web-stub}}

6 : JSON|Data serialization formats|Markup languages|XML markup languages|XML-based standards|World Wide Web Consortium standards

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/27 21:25:01