I'm learning Java 8 with REST and from my microservice I'm calling a REST service and I receive a JSON object. After that I need to delete the space from beginning and the end and after that to send it to frontend.
For example I have this model object:
public class User {
@JsonProperty("name")
private String name = null;
@JsonProperty("education")
private String education = null;
@JsonProperty("phone")
private String phone = null;
@JsonProperty("age")
private String age = null;
public User() {
}
........
}
So I'm calling this external service and I receive this kind of response:
{
"name": " John Book",
"education": " Faculty of Computers ",
"phone": "00448576948375 ",
"age": " 20 "
}
Now I need to clean all the spaces from the begining and the end for every field and to transform it in this:
{
"name": "John Book",
"education": "Faculty of Computers",
"phone": "00448576948375",
"age": "20"
}
How can I do this kind of implementation? Thank you!