HAL + JSON的适当媒体类型是什么?

时间:2021-06-07 19:34:30

I'm using Spring to create a RESTful service and I'm curious about the syntax for media-types.

我正在使用Spring创建RESTful服务,我对媒体类型的语法感到好奇。

From my understanding, the general media-type for HAL+JSON is application/hal+json. Also, from my understanding, a vendor-specific custom media-type that supports HAL+JSON would be something like application/vnd.api.entity.hal+json. However, I have also seen application/vnd.api.entity+hal+json. Which one is correct?

根据我的理解,HAL + JSON的一般媒体类型是application / hal + json。另外,根据我的理解,支持HAL + JSON的特定于供应商的自定义媒体类型将类似于application / vnd.api.entity.hal + json。但是,我也看过application / vnd.api.entity + hal + json。哪一个是正确的?

Also, what would the correct wild-card type be for HAL+JSON? Would it be application/*.hal+json or application/*+hal+json. Links to any pertinent RFC's would be appreciated. Thanks!

另外,对于HAL + JSON,正确的通配符类型是什么?它是application / * .hal + json还是application / * + hal + json。任何相关RFC的链接将不胜感激。谢谢!

1 个解决方案

#1


6  

application/vnd.api.entity+json

application/vnd.api.entity.hal+json would only make sense if you plan to provide your data also without support for HAL. The client has to know the structure of the content anyway and HAL is part of it.

application / vnd.api.entity.hal + json只有在你不打算支持HAL的情况下计划提供数据时才有意义。无论如何,客户必须知道内容的结构,HAL是其中的一部分。

application/vnd.api.entity+hal+json is just wrong. The standard states that only registered suffixes should be used. It also refers to them as "Structured Syntax Suffixes". So it's quite clear that it's about how to read data not about its meaning. Only one suffix is allowed and more wouldn't make sense.

application / vnd.api.entity + hal + json是错误的。该标准规定只应使用已注册的后缀。它还将它们称为“结构化语法后缀”。所以很清楚它是关于如何读取数据而不是它的含义。只允许一个后缀,更多没有意义。

Think about it as application/semantic+syntax, or application/what's in it + how to read it.

将其视为应用程序/语义+语法,或应用程序/其中的内容+如何阅读它。

#1


6  

application/vnd.api.entity+json

application/vnd.api.entity.hal+json would only make sense if you plan to provide your data also without support for HAL. The client has to know the structure of the content anyway and HAL is part of it.

application / vnd.api.entity.hal + json只有在你不打算支持HAL的情况下计划提供数据时才有意义。无论如何,客户必须知道内容的结构,HAL是其中的一部分。

application/vnd.api.entity+hal+json is just wrong. The standard states that only registered suffixes should be used. It also refers to them as "Structured Syntax Suffixes". So it's quite clear that it's about how to read data not about its meaning. Only one suffix is allowed and more wouldn't make sense.

application / vnd.api.entity + hal + json是错误的。该标准规定只应使用已注册的后缀。它还将它们称为“结构化语法后缀”。所以很清楚它是关于如何读取数据而不是它的含义。只允许一个后缀,更多没有意义。

Think about it as application/semantic+syntax, or application/what's in it + how to read it.

将其视为应用程序/语义+语法,或应用程序/其中的内容+如何阅读它。