我曾经使用Jersey 1.16过JSON,但现在我很难使用 Jersey 2.0(实现 JAX-RS 2.0)来使用 JSON。
我有这样的 JSON 响应:
{
    "id": 105430,
    "version": 0,
    "cpf": "55443946447",
    "email": "maria@teste.br",
    "name": "Maria",
}
以及使用它的方法:
public static JSONObject get() {
   String url = "http://127.0.0.1:8080/core/api/person";
   URI uri = URI.create(url);
   final Client client = ClientBuilder.newClient();
   WebTarget webTarget = client.target(uri);            
   Response response = webTarget.request(MediaType.APPLICATION_JSON).get();
   if (response.getStatus() == 200) {      
      return response.readEntity(JSONObject.class);
   }
}
我也试过:
return webTarget.request(MediaType.APPLICATION_JSON).get(JSONObject.class);
但是jSONObject 返回的是 null。我不明白我的错误,因为响应正常!