public static JavaType getCollectionType(Class<?> collectionClass, Class<?>... elementClasses) { return mapper.getTypeFactory().constructParametricType(collectionClass, elementClasses); }
public static JavaType getCollectionType(Class<?> collectionClass, Class<?>... elementClasses) { return mapper.getTypeFactory().constructParametricType(collectionClass, elementClasses); }
public static KafkaCheckpoint deserialize(InputStream inputStream) throws IOException { TypeFactory typeFactory = _mapper.getTypeFactory(); MapType mapType = typeFactory.constructMapType(HashMap.class, Integer.class, Long.class); HashMap<Integer, Long> checkpoint = _mapper.readValue(inputStream, mapType); return new KafkaCheckpoint(checkpoint); }
@Override public <T> T fromJSON(String jsonString, Type javaType) throws Exception { JavaType type = MAPPER.getTypeFactory().constructType(javaType); return MAPPER.readValue(jsonString, type); } }
mapper.readValue(userList, mapper.getTypeFactory() .constructCollectionType(List.class, MongoPrimeUser.class));
/** * Deserialize Notification Definition and convert all config to Key Value Pairs * @param notificationDef * @return * @throws Exception */ public static List<Map<String,String>> deserializeNotificationConfig( String notificationDef ) throws Exception { CollectionType mapCollectionType = OBJECT_MAPPER.getTypeFactory().constructCollectionType(List.class, Map.class); return OBJECT_MAPPER.readValue(notificationDef, mapCollectionType); }
private JavaType registrationResponseType(Class<?> type) { return mapper.getTypeFactory().constructParametricType(Response.class, type); }
public static List<String> jsonToList(String jsonString) throws IOException { ObjectMapper mapper = new ObjectMapper(); CollectionType type = mapper.getTypeFactory().constructCollectionType(List.class, String.class); List<String> data = mapper.readValue(jsonString, type); return data; } }
/** * @param payloadClass used to validate payloads when deserializing */ public JsonInstanceSerializer(Class<T> payloadClass) { this.payloadClass = payloadClass; mapper = new ObjectMapper(); type = mapper.getTypeFactory().constructType(ServiceInstance.class); }
private JavaType entryResponseType(Class<?> type) { return mapper.getTypeFactory().constructParametricType(Response.class, type); }
@Override public <T> Collection<T> deSerCollection(String json, Object collectionType, Class<T> elementType) throws Exception { return mapper.readValue(json, mapper.getTypeFactory() .constructCollectionType(((Collection<T>)collectionType).getClass(), elementType)); }
public <T> T deSer(String json, Class<? extends Collection> collectionType, Class<T> type) throws Exception { return (T) mapper.readValue(json, mapper.getTypeFactory() .constructCollectionType(collectionType, type)); }
public static Map<String, Object> jsonToMap(String jsonString) throws IOException { ObjectMapper mapper = new ObjectMapper(); MapType type = mapper.getTypeFactory().constructMapType(Map.class, String.class, Object.class); Map<String, Object> data = mapper.readValue(jsonString, type); return data; }
/** * @param payloadClass used to validate payloads when deserializing */ public JsonInstanceSerializer(Class<T> payloadClass) { this.payloadClass = payloadClass; mapper = new ObjectMapper(); type = mapper.getTypeFactory().constructType(ServiceInstance.class); }
public static <T> List<T> unserializeFromJsonAsList(String json, Class<T> cls) { try { List<T> object = mapper.readValue(json, mapper.getTypeFactory() .constructCollectionType(ArrayList.class, cls)); return object; } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } }
@VisibleForTesting JsonInstanceSerializer(Class<T> payloadClass, boolean compatibleSerializationMode, boolean failOnUnknownProperties) { this.payloadClass = payloadClass; this.compatibleSerializationMode = compatibleSerializationMode; mapper = new ObjectMapper(); mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, failOnUnknownProperties); type = mapper.getTypeFactory().constructType(ServiceInstance.class); }
public static KafkaCheckpoint deserialize(InputStream inputStream) throws IOException { TypeFactory typeFactory = _mapper.getTypeFactory(); MapType mapType = typeFactory.constructMapType(HashMap.class, Integer.class, Long.class); HashMap<Integer, Long> checkpoint = _mapper.readValue(inputStream, mapType); return new KafkaCheckpoint(checkpoint); }
public static KafkaCheckpoint deserialize(InputStream inputStream) throws IOException { TypeFactory typeFactory = _mapper.getTypeFactory(); MapType mapType = typeFactory.constructMapType(HashMap.class, Integer.class, Long.class); HashMap<Integer, Long> checkpoint = _mapper.readValue(inputStream, mapType); return new KafkaCheckpoint(checkpoint); }
public <T extends Serializable> List<T> deserializeUnformattedList(String source, Class<T> contentType) { try { CollectionType type = unformattedMapper.getTypeFactory().constructCollectionType(List.class, contentType); return unformattedMapper.readValue(source, type); } catch (IOException e) { throw new SerializationException(e); } }
public static KafkaCheckpoint deserialize(InputStream inputStream) throws IOException { TypeFactory typeFactory = _mapper.getTypeFactory(); MapType mapType = typeFactory.constructMapType(HashMap.class, Integer.class, Long.class); HashMap<Integer, Long> checkpoint = _mapper.readValue(inputStream, mapType); return new KafkaCheckpoint(checkpoint); }