繁体   English   中英

如何覆盖 org.springframework.hateoas.Resources 将内容序列化为 List 以序列化名称

[英]How to override org.springframework.hateoas.Resources serialize content as List to serialize the name

Jackson 正在序列化没有类型擦除的列表。 当 GET 方法返回资源 object 时,是否可以重写以从资源中删除类型

{ 
"_embedded": {
    "customObjList": [
        {
            "fld1": "a",
            "_links": {
                "self": {
                    "href": "http://..."
                }
            }
        }
    ]
}

}

预期的

{ 
"_embedded": {
    "customObj": [
        {
            "fld1": "a",
            "_links": {
                "self": {
                    "href": "http://..."
                }
            }
        }
    ]
}

}

在资源 class 上使用@Relation更改默认集合名称

@Relation(collectionRelation = "customObj")
class CustomObjResource{ 
   ...
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM