When developing our API in spring boot that interacts with a third party API, I have to create a DTO to populate and send to a third party. Thing is, the required JSON has a ton of nested objects. For example:
{
"profile": {
"firstName": "firstname",
"credentials": {
"password" : {
"hook": {
"type": "default"
}
}
}
}
}
So, what is simple to express in a JSON object is not simple to express in POJO/DTO classes, due to the high number of nested objects.
Should I create public or anonymous classes for all the nested properties? Or is there a better way to do this?
For example using anonymous, I can keep everything in one java file by not making the subobjects public. What are your techniques for this?