How to avoid complex Model class in Spring boot?

I have a json request message which I am going to receive in my restcontroller.

{

address:{

addressline:{

phone:{

primary:"989898000",

secondary:"00909000"

}

}

addressline:{

///

}

}

}

then I should be having several model classes like this to receive this message.

Model{

Address address;

}

Address{

List addressline;

}

AddressLine{

Phone phone;

}

Phone{

String primary;

String secondary;

}

Can I skip all these model class creation and have just one class only .

something like this :

Model {

String primaryInphoneInaddresslineInaddress;

String secondaryInphoneInaddresslineInaddress;

}

This could reduce a lot of boilerplate code and can be useful also when we are going to extract message from this json message and also If we need to insert any value...

Read More »

By: StackOverFlow - Tuesday, 13 March

Related Posts