java - Custom json when using javers library
问题描述
I am using javers library to compare two objects. I know that the library has the capability to create a json with the differences between two objects. My question is, if I can customize that json?
Using javers.getJsonConverter().toJson(diff)
I get the following json as per the documentation
{
"changeType": "ValueChange",
"globalId": {
"valueObject": "....Address",
"ownerId": {
"entity": "Employee",
"cdoId": "Frodo"
},
"fragment": "primaryAddress"
},
"property": "city",
"left": "Shire",
"right": "Mordor"
}
but I don't need the changeType
or globalId
. What would be the best way to get just property, left, right properties and also rename properties e.g rename left to old.
I tried using the registerValueTypeAdapter
method with a TypeAdapter for the ValueChange class but unsuccessfully.
解决方案
看官方文档: LINK
推荐阅读
- angular - 获取错误作为类型的参数 '{ headers: HttpHeaders; }' 不可分配给“HttpParamsOptions”类型的参数
- ios - 我需要从我的 firebase 数据库中获取数据并将其放入标签中,但数据需要与我的 tableView 单元格标题相对应
- javascript - Concat $scope variables
- protocol-buffers - 如何插入重复的ptrfiled,就像vector.insert(iterator)
- bash - 使用 jq 解析 JSON 数组
- c - 试图将二进制数连接成一个值
- javascript - 验证循环中的元素
- python - (Pycharm docker setting)Connection refused:no further information
- dart - 我想从第 6 页回到第 3 页并删除堆栈 Page 4,5,6 吗?(图片示例)
- web-scraping - 使用 beautifulsoup 从类中提取文本