簡體   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