List of usage examples for com.fasterxml.jackson.core.type TypeReference TypeReference
protected TypeReference()
From source file:com.nesscomputing.jackson.datatype.CommonsLang3SerializerTest.java
@Test public void testTrumpetPairCompatibility() throws IOException { Pair<String, Boolean> pair = mapper.readValue("{\"car\":\"foo\",\"cdr\":true}", new TypeReference<Pair<String, Boolean>>() { });/*from w w w. j a va 2 s . c om*/ assertEquals("foo", pair.getKey()); assertEquals(true, pair.getValue()); }
From source file:com.evrythng.java.wrapper.service.ActionService.java
/** * Gets the custom types and the built-in action types. *//*from w w w . ja v a2 s . c om*/ public Builder<List<ActionType>> actionTypesReader() throws EvrythngClientException { return get(PATH_ACTIONS, new TypeReference<List<ActionType>>() { }); }
From source file:com.nebhale.jsonpath.JsonPathTest.java
@Test public void stringInputTypeReferenceOutputStatic() { assertNotNull(JsonPath.read("$", STRING_VALID, new TypeReference<JsonNode>() { })); }
From source file:edu.asu.cse564.samples.crud.io.GradebookIO.java
public static List<Gradebook> readFromGradebook(String filename) { //GradebookIO gbio = new GradebookIO(); //String path = gbio.getPath(filename); String path = filename;//from ww w.ja va2 s . c o m File file = new File(filename); // if file doesnt exists, then create it if (!file.exists()) { LOG.info("Creating file as it does not exits"); try { file.createNewFile(); } catch (IOException ex) { Logger.getLogger(GradebookIO.class.getName()).log(Level.SEVERE, null, ex); } LOG.debug("Created file = {}", file.getAbsolutePath()); return null; } LOG.info("File path = {}", file.getAbsolutePath()); try (BufferedReader br = new BufferedReader(new FileReader(path))) { StringBuilder sb = new StringBuilder(); String sCurrentLine; while ((sCurrentLine = br.readLine()) != null) { sb.append(sCurrentLine); } if (sb.toString() != null && !sb.toString().trim().equals("")) { List<Gradebook> gblist = new ArrayList<Gradebook>(); gblist = (List<Gradebook>) Converter.convertFromJsonToObject(sb.toString(), new TypeReference<List<Gradebook>>() { }); return gblist; } } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:ch.ralscha.extdirectspring.controller.RouterControllerStoreAlwaysWrapResponseTest.java
@Test public void testNoArgumentsNoRequestParameters() { ExtDirectStoreResult<Row> rows = (ExtDirectStoreResult<Row>) ControllerUtil.sendAndReceive(mockMvc, "remoteProviderStoreRead", "method1", new TypeReference<ExtDirectStoreResult<Row>>() {/* nothing_here */ });/*from w w w. j a v a 2 s. c o m*/ RouterControllerStoreTest.assert100Rows(new ArrayList<Row>(rows.getRecords()), ""); }
From source file:org.redisson.spring.cache.CacheConfigSupport.java
public Map<String, CacheConfig> fromYAML(String content) throws IOException { return yamlMapper.readValue(content, new TypeReference<Map<String, CacheConfig>>() { });/* w w w .ja va2s . com*/ }
From source file:com.vmware.photon.controller.nsxclient.apis.DhcpServiceApi.java
/** * Gets a DHCP relay service profile./*from w w w . j a v a 2 s . c om*/ */ public void getDhcpRelayProfile(String id, FutureCallback<DhcpRelayProfile> responseCallback) throws IOException { getAsync(SERVICE_PROFILES_BASE_PATH + "/" + id, HttpStatus.SC_OK, new TypeReference<DhcpRelayProfile>() { }, responseCallback); }
From source file:net.nullschool.grains.jackson.datatype.BasicCollectionsTest.java
@Test public void test_basicConstSortedSet() throws IOException { ConstSortedSet<Integer> set = emptySortedSet(null); for (int i = 0; i < 10; i++) { ObjectMapper mapper = newGrainsObjectMapper(); byte[] data = mapper.writeValueAsBytes(set); ConstSortedSet<?> actual = mapper.readValue(data, new TypeReference<ConstSortedSet<Integer>>() { });/*from w w w .j a v a 2 s . c om*/ CollectionTestingTools.compare_sorted_sets(set, actual); set = set.with(i); } }
From source file:com.networknt.light.server.handler.loader.Loader.java
public static void login(String host, String userId, String password) throws Exception { Map<String, Object> inputMap = new HashMap<String, Object>(); inputMap.put("category", "user"); inputMap.put("name", "signInUser"); inputMap.put("readOnly", false); Map<String, Object> data = new HashMap<String, Object>(); data.put("userIdEmail", userId); data.put("password", password); data.put("rememberMe", true); data.put("clientId", "example@Browser"); inputMap.put("data", data); HttpPost httpPost = new HttpPost(host + "/api/rs"); StringEntity input = new StringEntity( ServiceLocator.getInstance().getMapper().writeValueAsString(inputMap)); input.setContentType("application/json"); httpPost.setEntity(input);//w w w . j av a 2 s .co m CloseableHttpResponse response = httpclient.execute(httpPost); try { //System.out.println(response.getStatusLine()); HttpEntity entity = response.getEntity(); BufferedReader rd = new BufferedReader(new InputStreamReader(entity.getContent())); String json = ""; String line = ""; while ((line = rd.readLine()) != null) { json = json + line; } //System.out.println("json = " + json); Map<String, Object> jsonMap = ServiceLocator.getInstance().getMapper().readValue(json, new TypeReference<HashMap<String, Object>>() { }); jwt = (String) jsonMap.get("accessToken"); EntityUtils.consume(entity); } catch (Exception e) { e.printStackTrace(); } finally { response.close(); } }