1 package eu.ehri.project.persistence; 2 3 import com.fasterxml.jackson.core.JsonParser; 4 import com.fasterxml.jackson.core.type.TypeReference; 5 import com.fasterxml.jackson.databind.DeserializationContext; 6 import com.fasterxml.jackson.databind.JsonDeserializer; 7 import eu.ehri.project.exceptions.DeserializationError; 8 9 import java.io.IOException; 10 import java.util.Map; 11 12 public class BundleDeserializer extends JsonDeserializer<Bundle> { 13 private static final TypeReference<Map<String, Object>> tref = new TypeReference<Map<String, Object>>() { 14 }; 15 16 @Override 17 public Bundle deserialize(JsonParser parser, DeserializationContext context) throws IOException { 18 try { 19 return DataConverter.dataToBundle(parser.readValueAs(tref)); 20 } catch (DeserializationError deserializationError) { 21 throw new IOException(deserializationError); 22 } 23 } 24 }