如何de(序列化)_link,以便“ rel&quot”的价值值以元素的形式出现,_link作为嵌套的JSON
Spring Hatios最新的是将链接保留为数组而不是嵌套的JSON,并将关系名称保留为“ Rel”。我们希望“ rel”值作为儿童jsons root名称。请参阅当前和预期的行为。
当前行为:
[
{
"id": "id-1",
"name": "abc",
"description": "abc",
"enrollments": [
{
"links": [
{
"rel": "fees",
"id": "feesId-1",
"href": "xyz"
},
{
"rel": "rates",
"id": "ratesId-1",
"href": "abc"
}
]
}
]
}
]
预期:
[
{
"id": "id-1",
"name": "abc",
"description": "abc",
"enrollments": [
{
"id": "1",
"end_timestamp": "2025-12-31T16:06:05Z",
"_links": {
"rates": {
"id": "ratesId-1",
"href": "abc"
},
"fees": {
"id": "feesId-1",
"href": "xyz"
}
}
}
]
}
]
Spring hatios latest is keeping links as array rather than nested json and keeping relation name as "rel". We want "rel" value as child jsons root name. Please see the current and expected behaviour.
CURRENT BEHAVIOUR:
[
{
"id": "id-1",
"name": "abc",
"description": "abc",
"enrollments": [
{
"links": [
{
"rel": "fees",
"id": "feesId-1",
"href": "xyz"
},
{
"rel": "rates",
"id": "ratesId-1",
"href": "abc"
}
]
}
]
}
]
EXPECTED:
[
{
"id": "id-1",
"name": "abc",
"description": "abc",
"enrollments": [
{
"id": "1",
"end_timestamp": "2025-12-31T16:06:05Z",
"_links": {
"rates": {
"id": "ratesId-1",
"href": "abc"
},
"fees": {
"id": "feesId-1",
"href": "xyz"
}
}
}
]
}
]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
返回
Returning CollectionModel instead of List resoloved the issue in my case.