List of usage examples for com.fasterxml.jackson.core.type TypeReference TypeReference
protected TypeReference()
From source file:com.blacklocus.jres.request.search.JresSearchBodyTest.java
@Test public void testFields() { String index = "JresSearchBodyTest.testFields".toLowerCase(); String type = "test"; jres.quest(new JresIndexDocument(index, type, of("character", "dino"))); jres.quest(new JresRefresh(index)); TypeReference<Map<String, String>> typeRef = new TypeReference<Map<String, String>>() { };/*from ww w . j a v a 2 s . co m*/ JresSearchReply reply; List<Map<String, String>> results; Map<String, String> result; // no setting reply = jres.quest(new JresSearch(index, type, new JresSearchBody())); results = reply.getHitsAsType(typeRef); Assert.assertEquals(1, results.size()); result = results.get(0); Assert.assertEquals("dino", result.get("character")); // no fields reply = jres.quest(new JresSearch(index, type, new JresSearchBody().fields())); results = reply.getHitsAsType(typeRef); Assert.assertEquals(1, results.size()); result = results.get(0); Assert.assertNull(result); // non-default fields reply = jres.quest(new JresSearch(index, type, new JresSearchBody().fields("_timestamp"))); results = reply.getHitsAsType(typeRef); Assert.assertEquals(1, results.size()); result = results.get(0); Assert.assertNull(result); }
From source file:org.eda.fpsrv.FPParams.java
public void setFromJSONString(String jsonString) throws IOException { LinkedHashMap<String, String> h_map; h_map = new ObjectMapper().readValue(jsonString, new TypeReference<LinkedHashMap<String, Object>>() { });//from w w w. j av a 2s . c o m FPProperty property; for (String key : properties.keySet()) { if (h_map.containsKey(key)) { property = properties.get(key); property.setValue(h_map.get(key)); } } }
From source file:org.mayocat.shop.payment.store.jdbi.mapper.GatewayCustomerDataMapper.java
@Override public GatewayCustomerData map(int index, ResultSet resultSet, StatementContext ctx) throws SQLException { UUID customerId = (UUID) resultSet.getObject("customer_id"); String gateway = resultSet.getString("gateway"); ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new GuavaModule()); try {/* w w w . j av a2 s .c o m*/ Map<String, Object> data = mapper.readValue(resultSet.getString("customer_data"), new TypeReference<Map<String, Object>>() { }); return new GatewayCustomerData(customerId, gateway, data); } catch (IOException e) { final Logger logger = LoggerFactory.getLogger(GatewayCustomerDataMapper.class); logger.error("Failed to de-serialize gateway customer data", e); return null; } }
From source file:com.github.nmorel.gwtjackson.jackson.options.WriteNullMapValuesOptionJacksonTest.java
@Test public void testWriteNonNullValues() { objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false); WriteNullMapValuesOptionTester.INSTANCE .testWriteNonNullValues(createWriter(new TypeReference<Map<String, String>>() { }));/* w w w .ja v a2s . c om*/ }
From source file:com.github.nmorel.gwtjackson.jackson.advanced.jsontype.JsonTypeWithEnumJacksonTest.java
@Test public void testSerializeWithoutJsonTypeInfo() { JsonTypeWithEnumTester.INSTANCE/* w w w . jav a 2 s.c o m*/ .testSerializeWithoutJsonTypeInfo(createWriter(new TypeReference<List<HasCode>>() { })); }
From source file:edumsg.shared.JsonMapper.java
public HashMap<String, String> deserialize() throws IOException { ObjectMapper mapper = new ObjectMapper(); return mapper.readValue(json, new TypeReference<HashMap<String, String>>() { });//from w ww . j a v a 2s .c o m }
From source file:com.github.nmorel.gwtjackson.jackson.options.OrderMapEntriesByKeysOptionJacksonTest.java
@Test public void testWriteOrdered() { objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true); OrderMapEntriesByKeysOptionTester.INSTANCE .testWriteOrdered(createWriter(new TypeReference<LinkedHashMap<String, Integer>>() { }));//from w ww . ja va 2 s .c om }
From source file:ru.jts.common.network.ClientPacket.java
protected Map<String, String> readJson() { short size = content.readUnsignedByte(); byte[] json = new byte[size]; content.readBytes(json);/*from w w w . j a va2 s .co m*/ ObjectMapper om = new ObjectMapper(); try { return om.readValue(json, new TypeReference<Map<String, String>>() { }); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:org.mayocat.shop.payment.store.jdbi.mapper.GatewayTenantDataMapper.java
@Override public GatewayTenantData map(int index, ResultSet resultSet, StatementContext ctx) throws SQLException { UUID tenantId = (UUID) resultSet.getObject("tenant_id"); String gateway = resultSet.getString("gateway"); ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new GuavaModule()); try {//from w w w .j av a 2s . c om Map<String, Object> data = mapper.readValue(resultSet.getString("tenant_data"), new TypeReference<Map<String, Object>>() { }); return new GatewayTenantData(tenantId, gateway, data); } catch (IOException e) { final Logger logger = LoggerFactory.getLogger(GatewayTenantDataMapper.class); logger.error("Failed to de-serialize gateway tenant data", e); return null; } }
From source file:com.netflix.edda.EddaRoute53Client.java
public ListHostedZonesResult listHostedZones(ListHostedZonesRequest request) { TypeReference<List<HostedZone>> ref = new TypeReference<List<HostedZone>>() { };// www . jav a2 s . c o m String url = config.url() + "/api/v2/aws/hostedZones;_expand"; try { List<HostedZone> hostedZones = parse(ref, doGet(url)); return new ListHostedZonesResult().withHostedZones(hostedZones); } catch (IOException e) { throw new AmazonClientException("Faled to parse " + url, e); } }