What is the best way to represent below phoneNumbers. I know you can achieve this by defining a list of phoneNumber Class. But I'm not a big fan of creating POJOs, since it's only a single key-value pair. Are there any alternative ways such as Jackson annotation can do the same job? Don't worry about too much on the sample JSON below this is just an example, the phoneNumber array has to be serialized to array of objects
I have below class defined:
class Person {
private String firstName;
private String lastName;
private int[] phoneNumbers;
}
I expect output something like this:
{
"firstName": "John",
"lastName": "Doe",
"phoneNumbers": [
{ "phoneNumber": "123456" },
{ "phoneNumber": "321123" },
{ "phoneNumber": "123555" }
]
}