首页 > 解决方案 > 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.

标签: javajavers

解决方案


看官方文档: LINK


推荐阅读