List of usage examples for com.fasterxml.jackson.core.type TypeReference TypeReference
protected TypeReference()
From source file:eu.jasha.demo.sbtfragments.CitiesInitializer.java
@Override public void afterPropertiesSet() throws Exception { Resource resource = new ClassPathResource(citiesFile); List<City> cities;/* w w w. j ava2 s.c o m*/ try (InputStream inputStream = resource.getInputStream()) { cities = objectMapper.readValue(inputStream, new TypeReference<List<City>>() { }); } for (City city : cities) { cityDao.add(city); } }
From source file:com.github.nmorel.gwtjackson.jackson.advanced.GenericsJacksonTest.java
@Test public void testSerializeStringString() { GenericsTester.INSTANCE// w w w .j a v a 2 s. c om .testSerializeStringString(createWriter(new TypeReference<GenericTwoType<String, String>>() { })); }
From source file:com.vmware.photon.controller.api.client.resource.AuthRestApi.java
/** * Get auth status.//from www .j a v a 2 s.c om * * @return {@link Auth} details. * @throws IOException */ @Override public Auth getAuthStatus() throws IOException { String path = getBasePath(); HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null); this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK); return this.restClient.parseHttpResponse(httpResponse, new TypeReference<Auth>() { }); }
From source file:org.springframework.social.facebook.api.impl.json.TagListDeserializer.java
@SuppressWarnings("unchecked") @Override//from ww w . j a v a2 s . com public List<Tag> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new FacebookModule()); jp.setCodec(mapper); if (jp.hasCurrentToken()) { JsonNode dataNode = (JsonNode) jp.readValueAs(JsonNode.class).get("data"); return (List<Tag>) mapper.reader(new TypeReference<List<Tag>>() { }).readValue(dataNode); } return null; }
From source file:net.nikore.gozer.marathon.CallbackServlet.java
@Override public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException { Map<String, Object> eventResponse = mapper.readValue(servletRequest.getInputStream(), new TypeReference<Map<String, Object>>() { });/*w w w .ja va 2s . com*/ switch ((String) eventResponse.get("eventType")) { case "status_update_event": String taskStatus = (String) eventResponse.get("taskStatus"); if (!taskStatus.equals("TASK_STAGING") || !taskStatus.equals("TASK_STARTING")) { appCache.refreshClient((String) eventResponse.get("appId")); } break; case "api_post_event": Map<String, String> appDef = (Map<String, String>) eventResponse.get("appDefinition"); try { appCache.removeClient(appDef.get("id")); appCache.getClient(appDef.get("id")); } catch (ExecutionException e) { throw new ServletException(e); } break; case "app_terminated_event": appCache.removeClient((String) eventResponse.get("appId")); break; default: break; // } }
From source file:uk.co.sdev.async.http.ning.Parallel2SequentialCompletableFutureClientTest.java
@Override protected CompletableFuture<Optional<Denominator>> getDenominator() throws IOException { return completableFutureClient .get("http://localhost:9101/denominator", new TypeReference<Optional<Denominator>>() { }).handle(withFallback(Optional.<Denominator>empty())); }
From source file:fr.cph.chicago.parser.JsonParser.java
@NonNull public List<BikeStation> parseStations(@NonNull final InputStream stream) throws ParserException { try {/*from ww w. j a v a2s.co m*/ final DivvyDTO divvyJson = MAPPER.readValue(stream, new TypeReference<DivvyDTO>() { }); return divvyJson.getStations(); } catch (final IOException e) { throw new ParserException(TrackerException.ERROR, e); } finally { IOUtils.closeQuietly(stream); } }
From source file:net.holmes.core.business.version.release.ReleaseDaoImpl.java
/** * {@inheritDoc}/*from ww w.j a v a 2 s .co m*/ */ @Override public void updateRelease(final String releaseApiUrl) { try { // Parse json content from URL List<Release> releases = new ObjectMapper().readValue(new URL(releaseApiUrl), new TypeReference<List<Release>>() { }); // Get latest available release for (Release release : releases) { if (!release.isDraft()) { LOGGER.info("Latest Holmes release available {}", release.getName()); latestRelease = release; break; } } } catch (IOException e) { LOGGER.error(e.getMessage(), e); } }
From source file:com.excilys.ebi.gatling.jenkins.SimulationReport.java
public void readStatsFile() throws IOException, InterruptedException { ObjectMapper mapper = new ObjectMapper(); File jsonFile = locateStatsFile(); globalReport = mapper.readValue(jsonFile, new TypeReference<RequestReport>() { });//from w w w . j a v a 2s .c o m }
From source file:com.vmware.photon.controller.api.client.resource.SystemStatusApi.java
/** * Get system status.//w ww . j av a 2 s. co m * * @return {@link SystemStatus} details * @throws java.io.IOException */ public SystemStatus getSystemStatus() throws IOException { String path = getBasePath(); HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null); this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK); return this.restClient.parseHttpResponse(httpResponse, new TypeReference<SystemStatus>() { }); }