I'm developing an httpclient application that use a list<OBJECT>
from a RESTful web service in JSON format.
I want to use this result in JSON format.
This is my httpclient application class :
public class ClientAbortMethod {
public final static void main(String[] args) throws Exception {
CloseableHttpClient httpclient = HttpClients.createDefault();
try {
HttpGet httpget = new HttpGet("http://localhost:8080/structure/alldto");
System.out.println("Executing request " + httpget.getURI());
CloseableHttpResponse response = httpclient.execute(httpget);
try {
String data= EntityUtils.toString(response.getEntity());
System.out.println(data);
// Do not feel like reading the response body
// Call abort on the request object
httpget.abort();
} finally {
response.close();
}
} finally {
httpclient.close();
}
}
}
This is the result of executing this code
[{"ids":"#AB","champs":[ {"idChamp":1,"order":1,"type":"FROM"},{"idChamp":2,"order":2,"type":"TO"},{"idChamp":3,"order":3,"type":"TEXT"}]},{"ids":"#AC","champs":[{"idChamp":4,"order":1,"type":"FROM"},{"idChamp":5,"order":2,"type":"TO_MAIL"},{"idChamp":6,"order":3,"type":"TEXT"}]},{"ids":"tt","champs":[]}]
This is the restful web service
@RequestMapping("/alldto")
public List<StructureNotificationDto> GetALLStructureNotification() {
return StructureNotif.StructureDTOS();
}
How can I get the result of this web service in JSON format or other easy-to-manipulate format?