I have a link https://jsonplaceholder.typicode.com/posts which returns data in JSON format. How to convert that into Object format?
public String ExposeServices() {
RestTemplate restTemplate= new RestTemplate();
String forresouseURL="https://jsonplaceholder.typicode.com/posts";
ResponseEntity<String> response= restTemplate.getForEntity(forresouseURL, String.class);
Gson gson = new Gson(); // Or use new GsonBuilder().create();
String target2 = gson.toJson(response, User.class);
HashMap<String, String> jsonObject= response;
System.out.println(target2);
//response.getBody().
return target2;
}
This is what I have tried but its not returning any value.
I have to get JOSN value in Object format then have to insert In MySQL DB.