/** * Method called to locate deserializer for the passed root-level value. */ protected JsonDeserializer<Object> _findRootDeserializer(DeserializationConfig cfg, JavaType valueType) throws JsonMappingException { // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = _deserializerProvider.findTypedValueDeserializer(cfg, valueType, null); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; }
@Override public void resolve(DeserializationConfig config, DeserializerProvider provider) throws JsonMappingException { _valueDeserializer = provider.findValueDeserializer(config, _referencedType, _property); } }
/** * Method that can be called to check whether mapper thinks * it could deserialize an Object of given type. * Check is done * by checking whether a deserializer can be found for the type. * * @return True if mapper can find a serializer for instances of * given class (potentially serializable), false otherwise (not * serializable) */ public boolean canDeserialize(JavaType type) { return _deserializerProvider.hasValueDeserializerFor(copyDeserializationConfig(), type); }
keyDes = p.findKeyDeserializer(config, keyType, property); contentDeser = p.findValueDeserializer(config, contentType, property);
keyDes = p.findKeyDeserializer(config, keyType, property);
protected Object _unwrapAndDeserialize(JsonParser jp, JavaType rootType, DeserializationContext ctxt, JsonDeserializer<Object> deser) throws IOException, JsonParseException, JsonMappingException { SerializedString rootName = _deserializerProvider.findExpectedRootName(ctxt.getConfig(), rootType); if (jp.getCurrentToken() != JsonToken.START_OBJECT) { throw JsonMappingException.from(jp, "Current token not START_OBJECT (needed to unwrap root name '" +rootName+"'), but "+jp.getCurrentToken()); } if (jp.nextToken() != JsonToken.FIELD_NAME) { throw JsonMappingException.from(jp, "Current token not FIELD_NAME (to contain expected root name '" +rootName+"'), but "+jp.getCurrentToken()); } String actualName = jp.getCurrentName(); if (!rootName.getValue().equals(actualName)) { throw JsonMappingException.from(jp, "Root name '"+actualName+"' does not match expected ('"+rootName +"') for type "+rootType); } // ok, then move to value itself.... jp.nextToken(); Object result = deser.deserialize(jp, ctxt); // and last, verify that we now get matching END_OBJECT if (jp.nextToken() != JsonToken.END_OBJECT) { throw JsonMappingException.from(jp, "Current token not END_OBJECT (to match wrapper object with root name '" +rootName+"'), but "+jp.getCurrentToken()); } return result; }
public void addAbstractTypeResolver(AbstractTypeResolver resolver) { mapper._deserializerProvider = mapper._deserializerProvider.withAbstractTypeResolver(resolver); }
public void addKeyDeserializers(KeyDeserializers d) { mapper._deserializerProvider = mapper._deserializerProvider.withAdditionalKeyDeserializers(d); }
public void addDeserializers(Deserializers d) { mapper._deserializerProvider = mapper._deserializerProvider.withAdditionalDeserializers(d); }
public void addBeanDeserializerModifier(BeanDeserializerModifier modifier) { mapper._deserializerProvider = mapper._deserializerProvider.withDeserializerModifier(modifier); }
public void addValueInstantiators(ValueInstantiators instantiators) { mapper._deserializerProvider = mapper._deserializerProvider.withValueInstantiators(instantiators); }
keyDes = p.findKeyDeserializer(config, keyType, property); contentDeser = p.findValueDeserializer(config, contentType, property);
/** * Deprecated version of accessor method that was used before version 1.7. * Implemented as final to ensure that existing code does not accidentally * try to redefine it (given that it is not called by core mapper code) * * @deprecated As of version 1.7, use version that exposes context class * and property, instead of just types */ @Deprecated public final KeyDeserializer findKeyDeserializer(DeserializationConfig config, JavaType keyType) throws JsonMappingException { return findKeyDeserializer(config, keyType, null); }
throws IOException, JsonParseException, JsonMappingException SerializedString rootName = _provider.findExpectedRootName(ctxt.getConfig(), rootType); if (jp.getCurrentToken() != JsonToken.START_OBJECT) { throw JsonMappingException.from(jp, "Current token not START_OBJECT (needed to unwrap root name '"
public void addAbstractTypeResolver(AbstractTypeResolver resolver) { mapper._deserializerProvider = mapper._deserializerProvider.withAbstractTypeResolver(resolver); }
public void addKeyDeserializers(KeyDeserializers d) { mapper._deserializerProvider = mapper._deserializerProvider.withAdditionalKeyDeserializers(d); }
public void addDeserializers(Deserializers d) { mapper._deserializerProvider = mapper._deserializerProvider.withAdditionalDeserializers(d); }
public void addBeanDeserializerModifier(BeanDeserializerModifier modifier) { mapper._deserializerProvider = mapper._deserializerProvider.withDeserializerModifier(modifier); }
public void addValueInstantiators(ValueInstantiators instantiators) { mapper._deserializerProvider = mapper._deserializerProvider.withValueInstantiators(instantiators); }
/** * Method called to locate deserializer for the passed root-level value. */ protected JsonDeserializer<Object> _findRootDeserializer(DeserializationConfig cfg, JavaType valueType) throws JsonMappingException { // Sanity check: must have actual type... if (valueType == null) { throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = _provider.findTypedValueDeserializer(cfg, valueType, null); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; }