Java Converting Map to Objectclass A {
public static Object mapToObject (Map<String, Object> map, Class<?> beanClass) throws Exception {
if (map == null) {
return null;
}
ObjectMapper objectMapper = new ObjectMapper();
Object obj = objectMapper.convertValue(map, beanClass);
return obj;
}
public static Map<?, ?> objectToMap (Object obj) {
if (obj == null) {
return null;
}
ObjectMapper objectMapper = new ObjectMapper();
Map<?, ?> mappedObject = objectMapper.convertValue(obj, Map.class);
return mappedObject;
}
}