List of usage examples for com.fasterxml.jackson.core.type TypeReference TypeReference
protected TypeReference()
From source file:com.github.nmorel.gwtjackson.jackson.advanced.GenericsJacksonTest.java
@Test public void testDeserializeStringString() { GenericsTester.INSTANCE/*w ww . j av a2s . c o m*/ .testDeserializeStringString(createReader(new TypeReference<GenericTwoType<String, String>>() { })); }
From source file:test.com.wealdtech.jackson.modules.TriValModuleTest.java
@Test public void testDeserStrClear() throws Exception { final String ser = "\"\""; final TriVal<String> deser = this.mapper.readValue(ser, new TypeReference<TriVal<String>>() { });/*from w w w .j ava 2 s . c o m*/ assertTrue(deser.isClear()); }
From source file:pz.pzsensor.network.RESTRequester.java
public Metric getMetric(String metricName) { Metric result = null;/*from w ww. java 2 s .co m*/ try { String metricsUrl = this.serverAddress + METRICS_ENDPOINT; RestClient client = RestClient.builder().build(); Map<String, String> params = Maps.newHashMap(); params.put("name-like", metricName); List<Metric> metrics = client.get(metricsUrl, params, new TypeReference<List<Metric>>() { }); //Zakladam ze monitor zawsze zwraca albo jednoelementowa liste //albo pusta liste if (!metrics.isEmpty()) { result = metrics.get(0); } } catch (RestClientException ex) { Logger.getLogger(RESTRequester.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(RESTRequester.class.getName()).log(Level.SEVERE, null, ex); } return result; }
From source file:com.ibm.ws.lars.rest.model.RepositoryObjectList.java
protected static List<Map<String, Object>> readJsonState(byte[] json) throws InvalidJsonAssetException { try {//from w ww. j a v a 2s . c o m return reader.readValue(json, new TypeReference<List<Map<String, Object>>>() { }); } catch (JsonParseException e) { throw new InvalidJsonAssetException(e); } catch (JsonMappingException e) { throw new InvalidJsonAssetException(e); } catch (IOException e) { // No idea what would cause this. throw new InvalidJsonAssetException(e); } }
From source file:org.nebula.test.workflow.signal.SignalWithPoJoWorkflowTest.java
@Before public void setUp() { super.setUp(); startActivityWorker(BasicActivityImpl.class, realms); startWorkflowWorker(SignalWithPoJoWorkflowImpl.class, realms); client = new SignalWithPoJoWorkflowClientImpl(nebulaClient, workflowProfile, realms); client.test("nebula"); log.info("instanceId=" + client.getInstanceId()); String s = "[{\"name\":\"nebula\",\"addresses\":[\"beijing\",\"shanghai\"]},{\"name\":\"nebula\",\"addresses\":[\"guangzhou\"]}]"; try {/*from w w w. j a v a 2s.com*/ Object result = new ObjectMapper().readValue(s, new TypeReference<List<CustomPoJo>>() { }); log.info("result=" + result); } catch (Exception e) { log.error(e); } sleep(5); }
From source file:org.springframework.social.linkedin.api.impl.json.LikesListDeserializer.java
@Override public List<LinkedInProfile> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new LinkedInModule()); jp.setCodec(mapper);//from w w w. j a v a 2s .com if (jp.hasCurrentToken()) { JsonNode dataNode = jp.readValueAs(JsonNode.class).get("values"); List<LinkedInProfile> likes = new ArrayList<LinkedInProfile>(); // Have to iterate through list due to person sub object. for (JsonNode like : dataNode) { LinkedInProfile profile = mapper.reader(new TypeReference<LinkedInProfile>() { }).readValue(like.get("person")); likes.add(profile); } return likes; } return null; }
From source file:jp.co.gui.aruga.watch.ClockHttpRequest.java
public List<Todo> get(String category) throws IOException { String jsonUrl = url + "/json"; if (category != null) jsonUrl = jsonUrl + "?category=" + category; HttpGet request = new HttpGet(jsonUrl); HttpResponse hr = httpClient.execute(request); String result = EntityUtils.toString(hr.getEntity()); List<TodoResponse> todo = om.readValue(result, new TypeReference<List<TodoResponse>>() { });//from ww w .j av a 2 s. co m List<Todo> listT = new ArrayList<>(); for (TodoResponse todo1 : todo) { listT.add(todo1.getTodo()); } return listT; }
From source file:org.springframework.social.facebook.api.impl.json.ReferenceListAndCountDeserializer.java
@SuppressWarnings("unchecked") @Override// w w w . ja v a 2 s . c om public ListAndCount<Reference> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new FacebookModule()); jp.setCodec(mapper); if (jp.hasCurrentToken()) { JsonNode node = jp.readValueAs(JsonNode.class); JsonNode dataNode = node.get("data"); List<Reference> commentsList = dataNode != null ? (List<Reference>) mapper.reader(new TypeReference<List<Reference>>() { }).readValue(dataNode) : Collections.<Reference>emptyList(); JsonNode countNode = node.get("count"); int referenceCount = countNode != null ? countNode.intValue() : 0; return new ListAndCount<Reference>(commentsList, referenceCount); } return null; }
From source file:org.agorava.linkedin.jackson.LikesListDeserializer.java
@Override public List<LinkedInProfile> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectMapper mapper = BeanResolver.getInstance().resolve(ObjectMapper.class); jp.setCodec(mapper);//from ww w . j ava 2 s . c om if (jp.hasCurrentToken()) { JsonNode dataNode = jp.readValueAs(JsonNode.class).get("values"); List<LinkedInProfile> likes = new ArrayList<LinkedInProfile>(); // Have to iterate through list due to person sub object. for (JsonNode like : dataNode) { LinkedInProfile profile = mapper.reader(new TypeReference<LinkedInProfile>() { }).readValue(like.get("person")); likes.add(profile); } return likes; } return null; }
From source file:org.jahia.loganalyzer.services.stacktrace.internal.StackTraceServiceImpl.java
public void start() { InputStream defaultStackTraceDefinitionsInputStream = this.getClass() .getResourceAsStream("/stacktrace-definitions.json"); ObjectMapper mapper = new ObjectMapper(); try {//from www. j a v a 2s . c o m stackTraceDefinitions = mapper.readValue(defaultStackTraceDefinitionsInputStream, new TypeReference<List<StackTraceDefinition>>() { }); } catch (IOException e) { logger.error("Error loading default stack trace definitions", e); } if (stackTraceDefinitions == null) { stackTraceDefinitions = new ArrayList<>(); } }