予有這種響應格式從後端(URL是http://localhost:8080/App/api/currency):角資源與HATEOAS和應用/ HAL + JSON
{
"content": [
{
"code": "CHF",
"_links": [
{
"rel": "self",
"href": "http://localhost:8080/App/api/currency/CHF"
}
]
},
{
"code": "EUR",
"_links": [
{
"rel": "self",
"href": "http://localhost:8080/App/api/currency/EUR"
}
]
},
{
"code": "USD",
"_links": [
{
"rel": "self",
"href": "http://localhost:8080/App/api/currency/USD"
}
]
},
{
"code": "AUD",
"_links": [
{
"rel": "self",
"href": "http://localhost:8080/App/api/currency/AUD"
}
]
},
{
"code": "CAD",
"_links": [
{
"rel": "self",
"href": "http://localhost:8080/App/api/currency/CAD"
}
]
},
{
"code": "GBP",
"_links": [
{
"rel": "self",
"href": "http://localhost:8080/App/api/currency/GBP"
}
]
},
{
"code": "NZD",
"_links": [
{
"rel": "self",
"href": "http://localhost:8080/App/api/currency/NZD"
}
]
},
{
"code": "JPY",
"_links": [
{
"rel": "self",
"href": "http://localhost:8080/App/api/currency/JPY"
}
]
},
{
"code": "SEK",
"_links": [
{
"rel": "self",
"href": "http://localhost:8080/App/api/currency/SEK"
}
]
},
{
"code": "NOK",
"_links": [
{
"rel": "self",
"href": "http://localhost:8080/App/api/currency/NOK"
}
]
},
{
"code": "ISK",
"_links": [
{
"rel": "self",
"href": "http://localhost:8080/App/api/currency/ISK"
}
]
},
{
"code": "DKK",
"_links": [
{
"rel": "self",
"href": "http://localhost:8080/App/api/currency/DKK"
}
]
}
],
"_links": [
{
"rel": "self",
"href": "http://localhost:8080/App/api/currency"
}
]
}
要使用角查詢它我使用$resource's
查詢方法。但是,此響應結構不適用於$resource
:
- 查詢需要數組。在這裏,我有一個對象
- 陣列項目作爲單一資源
我怎樣才能使與$resource
即此響應工作指導其採取content
作爲構建$resource
對象的實際數據處理。還是有任何強大的解決方案呢?
您可以添加一個響應變換器。反應並不是真正的'hal + json'順便說一句。該配置可能缺少一些東西。 – zeroflagL