HAL JSON-标准是否允许有多个级别的嵌入?
我想知道是允许在JSON中嵌入更多的元素,还是只允许有一个级别 参见正常HAL示例:HAL JSON-标准是否允许有多个级别的嵌入?,json,web-services,rest,hal-json,Json,Web Services,Rest,Hal Json,我想知道是允许在JSON中嵌入更多的元素,还是只允许有一个级别 参见正常HAL示例: { "_links": { "self": { "href": "/orders" }, "curies": [{ "name": "ea", "href": "http://example.com/docs/rels/{rel}", "templated": true }], "next": { "href": "/orders?page=2" }, "ea:find": {
{
"_links": {
"self": { "href": "/orders" },
"curies": [{ "name": "ea", "href": "http://example.com/docs/rels/{rel}", "templated": true }],
"next": { "href": "/orders?page=2" },
"ea:find": {
"href": "/orders{?id}",
"templated": true
},
"ea:admin": [{
"href": "/admins/2",
"title": "Fred"
}, {
"href": "/admins/5",
"title": "Kate"
}]
},
"currentlyProcessing": 14,
"shippedToday": 20,
"_embedded": {
"ea:order": [{
"_links": {
"self": { "href": "/orders/123" },
"ea:basket": { "href": "/baskets/98712" },
"ea:customer": { "href": "/customers/7809" }
},
"total": 30.00,
"currency": "USD",
"status": "shipped"
}, {
"_links": {
"self": { "href": "/orders/124" },
"ea:basket": { "href": "/baskets/97213" },
"ea:customer": { "href": "/customers/12369" }
},
"total": 20.00,
"currency": "USD",
"status": "processing"
}]
}
}
问题是关于什么的(注意,第二个嵌入是第一个嵌入的子对象):
我本人正在阅读的文档表明,嵌入式资源与普通资源相同,因此它可以再次包含嵌入式资源?我也面临这个问题。答案似乎是肯定或否定 因为嵌入式资源可以 完整、部分或不一致的版本 ,则由实现者决定是否使用_嵌入式标记,或直接嵌入资源 在我看来,最好像他们使用链接时一样返回嵌入的资源。api的使用者可能已经编写了解析器来处理嵌入式资源(通常还包括_embedded标记) 4.1.2_嵌入 保留的“_embedded”属性是可选的 它是一个属性名称为链接关系类型的对象(如
由[RFC5988]定义,值为资源对象或
资源对象数组 嵌入式资源可能是完整、部分或不一致的版本 从目标URI提供的表示的
{
"_links" : {
"self" : {
"href" : "http://localhost:8090/fs/rest/roles/roleDefinition=Z1407031312513158080GIVMZ"
}
},
"_embedded" : {
"roles" : [ {
"_links" : {
"self" : {
"href" : "http://localhost:8090/fs/rest/roles/Z1407031312513168080XCAKL"
}
},
"id" : "Z1407031312513168080XCAKL",
"_embedded" : {
"roleDefinition" : {
"_links" : {
"self" : {
"href" : "http://localhost:8090/fs/rest/roledefinitions/Z1407031312513158080GIVMZ"
(rest ommitted)