o We are going to reuse the implementation we created so far
o But, the getMessage() is going to return the JSON data
o We will add this method to our SampleServiceImpl.java:
o But, the getMessage() is going to return the JSON data
o We will add this method to our SampleServiceImpl.java:
private String getJSONMessage() {
StringBuilder msg = new StringBuilder();
msg.append("[n");
msg.append(" {n");
msg.append(" "message": "message goes here"n");
msg.append(" }n");
msg.append("]n");
return msg.toString();
}
o The getMessage() method is changed from:
@Override
public String getMessage() throws IllegalArgumentException {
return "message goes here";
}
o To this, where we call the getJSONMessage() method:
@Override
public String getMessage() throws IllegalArgumentException {
return getJSONMessage();
}