我想知道是否允许在 JSON 中的 _embed 元素中包含更多的 _embed 元素,或者这个想法是否只有一个级别?
请参阅普通 HAL 示例:
{
"_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"
}]
}
}
以及问题是什么(注意第二个嵌入是第一个的孩子):
{
"_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)
我自己正在阅读http://stateless.co/hal_specification.html上的文档,因为嵌入式资源与普通资源相同,因此它可以再次包含嵌入式资源?