I need to read data from database and send it to some MQ in JSON format. I am using java 8,spring boot. My current process --
Read Data from DB --- > Map to POJO --- >Convert to JSON using object mapper (Jackson )
Problem with above is my Pojo classes need to be changed if JSON structure changes.
How can I avoid it? Below is the JSON schema that I have. Suppose if some field gets added to this schema. How can I avoid the code change? Can I make it dynamic? Eg. lets say some fields get added to fname,lname or address. How can I avoid the code change?
{
"name": {
"fname" : {
"displayName":"FirstName",
"dataType":"String"
}
"lname" : {
"displayName":"LastName",
"dataType":"String"
}
},
"address": {
"displayName":"Address",
"dataType":"String"
}
}