Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package model.dao;
- import com.fasterxml.jackson.core.type.TypeReference;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.sun.jersey.api.client.Client;
- import com.sun.jersey.api.client.WebResource;
- import model.pojo.User;
- import javax.ws.rs.core.MediaType;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.List;
- public class Test {
- public static void main(String[] args){
- Client client= Client.create();
- WebResource webResource=client.resource("http://localhost:9090/Facebook_API_war_exploded/rest/");
- String response = webResource.path("User/getAll").accept(MediaType.APPLICATION_JSON).get(String.class);
- ObjectMapper mapper =new ObjectMapper();
- List<User> users=new ArrayList<>();
- try {
- users=mapper.readValue(response, new TypeReference<List<User>>(){});
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment