I have rest service that return arraylist of object,and I have implemented jersy restful client to execute it,but I have problem in converting ZonedDateTime type to json so
I have fixed it,This is the code after updates
Client client = Client.create();
WebResource webResource = client
.resource("http://localhost:8080/adap/api/getScoreFactor");
ClientResponse response = webResource.accept("application/json")
.get(ClientResponse.class);
String output = response.getEntity(String.class);
Gson gson = new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new JsonDeserializer() {
@Override
public ZonedDateTime deserialize(JsonElement json, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
return ZonedDateTime.parse(json.getAsJsonPrimitive().getAsString());
}
}).create();
Type listType = new TypeToken>() {}.getType();
List scorefactors = gson.fromJson(output,listType);