In the previous method, we returned a string. Let's create a method that returns a proper JSON response. Take a look at the following method:
@GetMapping("/welcome-with-object")
public WelcomeBean welcomeWithObject() {
return new WelcomeBean("Hello World");
}
This preceding method returns a simple WelcomeBean initialized with a message: "Hello World".