Search code examples
javajsonjacksonfaker

Partial Update JSON / POJO fields


I have a JSON which I am using as a fabricated data to create a POJO using GSON. This is expected data for my tests. Next, I have data from the cucumber feature file which would override some of the fields in the already created POJO i.e. update expected data object. I was wondering if anybody has done this earlier or is aware of pattern which I can use to achieve this. In terms of approaches, in was wondering if makes more sense to create an updated json first from both the data sources or to create POJO from the first JSON first and then apply mutation.


Solution

  • I have found a way around - using Apache Velocity template instead of vanilla json files simplifies the implementation and provides flexibility.