予有这种响应格式从后端(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