How to Dynamically generate and retrieve JSON in Java code?

tronc2005

New Member
I have a use case where we have to send different JSONs to different servers.The difference is only between JSON keys, the meaning the keys carry is same and so is the data.For example server XYZ wants JSON data to be sent in this format:\[code\]{ "firstName":"Sam", "lastName":"Jones"}\[/code\]Now server ABC wants JSON data to be sent in this format:\[code\]{ "fName":"Sam", "lName":"Jones"}\[/code\]And firstName and lastName data is populated via a POJO.So, How do I achieve this? I do not want to clutter the code with if-else conditions.But wnat to have something which would work like a template loaded dynamically and create the JSON data and also retrieve it back to the POJO.
 
Back
Top