实体类直接转换会报错,所以需要特别转换:
Gson gson=new GsonBuilder().registerTypeAdapter(ZonedDateTime.class,new JsonDeserializer<ZonedDateTime>(){
@Override
public ZonedDateTime deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
return ZonedDateTime.parse(jsonElement.getAsJsonPrimitive().getAsString());
}
}).create();
return gson.fromJson(result,OrderDigestInfoResp.class);