use of com.fasterxml.jackson.dataformat.ion.IonParser in project jackson-dataformats-binary by FasterXML.
the class IonValueDeserializer method deserialize.
@Override
public IonValue deserialize(JsonParser jp, DeserializationContext ctxt) throws JacksonException {
Object embeddedObject = jp.getEmbeddedObject();
if (embeddedObject instanceof IonValue) {
return (IonValue) embeddedObject;
}
// We rely on the IonParser's IonSystem to wrap supported types into an IonValue
if (!(jp instanceof IonParser)) {
throw DatabindException.from(jp, "Unsupported parser for deserializing " + embeddedObject.getClass().getCanonicalName() + " into IonValue");
}
IonSystem ionSystem = ((IonParser) jp).getIonSystem();
if (embeddedObject instanceof Timestamp) {
return ionSystem.newTimestamp((Timestamp) embeddedObject);
}
if (embeddedObject instanceof byte[]) {
// The parser provides no distinction between BLOB and CLOB, deserializing to a BLOB is the safest choice.
return ionSystem.newBlob((byte[]) embeddedObject);
}
throw DatabindException.from(jp, "Cannot deserialize embedded object type " + embeddedObject.getClass().getCanonicalName() + " into IonValue");
}