@Override /** * All joynr objects are serialized with type information, so deserialize them as such */ public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonToken t = jp.getCurrentToken(); if (t == JsonToken.START_OBJECT) { return super.deserializeWithType(jp, ctxt, typeDeserializer); } return super.deserialize(jp, ctxt); } }
@Override /** * Arrays are not serialized with type information, so also need to deserialize them without */ public Object deserializeWithType(JsonParser jp, DeserializationContext ctxt, TypeDeserializer withTypeDeserializer) throws IOException, JsonProcessingException { JsonToken t = jp.getCurrentToken(); if (t == JsonToken.START_ARRAY) { return super.deserialize(jp, ctxt); } return super.deserializeWithType(jp, ctxt, withTypeDeserializer); }
@Override public Object deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException { // Use type deserializer if we have type information, even for scalar values if (typeDeserializer != null) { if (p.canReadTypeId()) { Object typeId = p.getTypeId(); if (typeId != null) { TypeIdResolver resolver = typeDeserializer.getTypeIdResolver(); // Make sure that we actually can resolve the type ID, otherwise we'll end up in a recursive loop if (resolver != null && resolver.typeFromId(ctxt, p.getTypeId().toString()) != null) { return typeDeserializer.deserializeTypedFromAny(p, ctxt); } } } } return super.deserializeWithType(p, ctxt, typeDeserializer); }