Springboot json to model without default constructor Springboot json to model without default constructor json json

Springboot json to model without default constructor


You can do it by defining Jackson custom deserializer for your model class.Look at the link below on how to implement and configure it.

http://wiki.fasterxml.com/JacksonHowToCustomDeserializers

http://www.baeldung.com/jackson-deserialization


You need to use a HttpMessageConverter, and receive the parameter as @RequestBody.

@RequestMapping(value= "", method = RequestMethod.POST)public Classroom create(@RequestBodyClassroom classroom) {    ... some checks ...    return classroomManager.create(classroom);}public class ClassroomConverter extends AbstractHttpMessageConverter<Classroom> {...}@Configuration@EnableWebMvc@ComponentScanpublic class WebConfiguration extends WebMvcConfigurerAdapter {    @Override    public void configureMessageConverters(List<HttpMessageConverter<?>> httpMessageConverters) {        httpMessageConverters.add(new ClassroomConverter(new MediaType("text", "csv")));    }}

Here there is a case similar to yours

http://www.beabetterdeveloper.com/2013/07/spring-mvc-requestbody-and-responsebody.html