List of usage examples for com.fasterxml.jackson.core.type TypeReference TypeReference
protected TypeReference()
From source file:com.addthis.hydra.kafka.KafkaUtils.java
public static Node parseBrokerInfo(int id, byte[] brokerInfo) { try {// ww w .ja va 2 s . com Map<String, Object> map = OBJECT_MAPPER.readValue(brokerInfo, new TypeReference<Map<String, Object>>() { }); return new Node(id, (String) map.get("host"), (Integer) map.get("port")); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:ConcurrentTest.java
@BeforeClass public static void setUpClass() throws IOException { List<HashResultHolder> list = new ObjectMapper().readValue( JacksonJacksumTest.class.getResourceAsStream("/jacksum_image.json"), new TypeReference<List<HashResultHolder>>() { });// www . ja v a 2 s .com IMAGE_FILE_RESULTS = list.stream() .collect(Collectors.toMap(HashResultHolder::getAlgorithm, Function.identity())); }
From source file:co.agileventure.jwtauth.web.controller.helper.JsonHelper.java
public Map<String, Object> getJsonMap(final String response) throws JsonParseException, JsonMappingException, IOException { return MAPPER.readValue(response, new TypeReference<Map<String, Object>>() { });/*from w w w.ja va2s. c o m*/ }
From source file:com.nesscomputing.sequencer.SequencerJsonSerializationTest.java
@Test public void testEmptySequencerSerialize() throws Exception { byte[] emptySeq = mapper.writeValueAsBytes(Sequencers.emptySequencer()); Sequencer<String> newEmptySeq = mapper.readValue(emptySeq, new TypeReference<Sequencer<String>>() { });//from w w w. j a va2s .com assertEquals(0, newEmptySeq.size()); }
From source file:com.cloudera.parcel.components.JsonParcelParser.java
public JsonParcelParser() { super(new TypeReference<ParcelDescriptor>() { }); }
From source file:com.nesscomputing.jackson.JacksonSerializerBinder.java
public static <T> SerializerBinderBuilder<T> builderOf(Binder binder, final TypeLiteral<T> literal) { final TypeReference<T> type = new TypeReference<T>() { @Override// w w w. j a v a2 s. c o m public Type getType() { return literal.getType(); } }; return new SerializerBinderBuilderImpl<T>(binder, type); }
From source file:uk.co.sdev.async.http.ning.Parallel2CompletableFutureClientTest.java
@Override protected CompletableFuture<Optional<Foo>> getFoo() throws IOException { return completableFutureClient.get("http://localhost:9101/foo", new TypeReference<Optional<Foo>>() { });/* w w w.j ava 2s . com*/ }
From source file:com.cloudera.parcel.components.JsonManifestParser.java
public JsonManifestParser() { super(new TypeReference<ManifestDescriptor>() { }); }
From source file:net.bafeimao.umbrella.servers.world.test.MiscTests.java
@Test public void test12() { String json = "[[1000002,500,100],[1000003,10,101],[1000004,100,-1]]"; List<List<Integer>> elements = JsonUtil.toBean(json, new TypeReference<List<List<Integer>>>() { });/* w ww.j a va 2 s . com*/ for (List<Integer> element : elements) { System.out.println(element); } List<List<Integer>> elements1 = JsonUtil.toBean(json, ArrayList.class); for (List<Integer> element : elements1) { System.out.println(element); } System.out.println(elements); }
From source file:tachyon.master.Dependency.java
/** * Create a new dependency from a JSON Element. * /* ww w . j a v a 2 s . c o m*/ * @param ele the JSON element * @return the loaded dependency * @throws IOException */ static Dependency loadImage(ImageElement ele, TachyonConf tachyonConf) throws IOException { Dependency dep = new Dependency(ele.getInt("depID"), ele.get("parentFiles", new TypeReference<List<Integer>>() { }), ele.get("childrenFiles", new TypeReference<List<Integer>>() { }), ele.getString("commandPrefix"), ele.getByteBufferList("data"), ele.getString("comment"), ele.getString("framework"), ele.getString("frameworkVersion"), ele.get("dependencyType", DependencyType.class), ele.get("parentDeps", new TypeReference<List<Integer>>() { }), ele.getLong("creationTimeMs"), tachyonConf); dep.resetUncheckpointedChildrenFiles( ele.get("unCheckpointedChildrenFiles", new TypeReference<List<Integer>>() { })); return dep; }