Ankit Bansal
Ankit Bansal

Reputation: 2358

Response Object for Spring Boot API's

I am developing an application with Spring boot.Now I have developed the API's and I want to return the JSON Output for the API's. So how do I create the response class & convert it to JSON? Will it be common class or do I have to create a response class for every API?

Upvotes: 0

Views: 4672

Answers (1)

Well assuming you're making a spring boot web application with @RequestMapping, you can just return your objects and Spring will automatically convert them to JSON. You can also return a ResponseEntity object if you wish to include headers or modify to HTTPStatus code

I recommend checking out the spring boot starter guide for RESTful webservices

Upvotes: 4

Related Questions