In my controller class m reading JSON data using ObjectMapper and after dat m storing these values in MyPojo class and now i want to print the content which is there in the POJO object. If I am doing system.out.println(pojo);
it is showing some hexadecimal value. So what should I do to get thee content.
This is my model class:
package com.ge.health.model;
import java.util.Date;
public class JSONmodel {
private String message;
private String data;
private String datetime;
public String getDatetime() {
return datetime;
}
public void setDatetime(String datetime) {
this.datetime = datetime;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
}
This is my main class Controller class
package com.ge.health.poc.controller;
import java.io.IOException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ge.health.model.JSONmodel;
@RestController
public class JSONSendController {
@RequestMapping(value="/messagejson",method= RequestMethod.POST)
@ResponseBody
public void helloService(@RequestBody(required = false) String input) throws JsonParseException, JsonMappingException, IOException {
ObjectMapper mapper = new ObjectMapper();
JSONValidationClass validate=new JSONValidationClass();
System.out.println("Service Says 123 - " + input);
boolean retValue = validate.isValidJSON(input);
System.out.println("this is the value:"+retValue);
JSONmodel pojodata = mapper.readValue(input, JSONmodel.class);
System.out.println(pojodata);
System.out.println(pojodata.toString());
}
}