/** * 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; } // es-hadoop: findType with 2 args have been removed since 1.9 so this code compiles on 1.8 (which has the fallback method) // es-hadoop: on 1.5 only the 2 args method exists, since 1.9 only the one with 3 args hence the if // Nope: need to ask provider to resolve it deser = _provider.findTypedValueDeserializer(cfg, valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type " + valueType); } _rootDeserializers.put(valueType, deser); return deser; }
@SuppressWarnings("unchecked") protected BackportedJacksonMappingIterator(JavaType type, JsonParser jp, DeserializationContext ctxt, JsonDeserializer<?> deser) { _type = type; _parser = jp; _context = ctxt; _deserializer = (JsonDeserializer<T>) deser; /* One more thing: if we are at START_ARRAY (but NOT root-level * one!), advance to next token (to allow matching END_ARRAY) */ if (jp != null && jp.getCurrentToken() == JsonToken.START_ARRAY) { JsonStreamContext sc = jp.getParsingContext(); // safest way to skip current token is to clear it (so we'll advance soon) if (!sc.inRoot()) { jp.clearCurrentToken(); } } }
/** * Search for any registered JsonDeserialize instances that have been declared using the * ServiceLoader. Add any found to the given mapper in a 'magic' module. */ private static void addDiscoverableDeserializers(final ObjectMapper mapper) { final ServiceLoader<JsonDeserializer> loader = ServiceLoader.load(JsonDeserializer.class); final Iterator<JsonDeserializer> iterator = loader.iterator(); final SimpleModule magic = new SimpleModule("magic", new Version(1, 0, 0, "")); while (iterator.hasNext()) { final JsonDeserializer<?> deserializer = iterator.next(); try { final Method deserialeMethod = deserializer.getClass() .getDeclaredMethod("deserialize", JsonParser.class, DeserializationContext.class); final Class<?> jsonType = deserialeMethod.getReturnType(); //noinspection unchecked magic.addDeserializer(jsonType, (JsonDeserializer) deserializer); } catch(Exception e) { throw new IllegalStateException(e); } } mapper.registerModule(magic); }
protected final JsonDeserializer<Object> _findDeserializer(DeserializationContext paramDeserializationContext, String paramString) throws IOException, JsonProcessingException { JavaType localJavaType; synchronized (this._deserializers) { localJsonDeserializer = (JsonDeserializer)this._deserializers.get(paramString); if (localJsonDeserializer != null) break label125; localJavaType = this._idResolver.typeFromId(paramString); if (localJavaType == null) throw paramDeserializationContext.unknownTypeException(this._baseType, paramString); } if ((this._baseType != null) && (this._baseType.getClass() == localJavaType.getClass())) localJavaType = this._baseType.narrowBy(localJavaType.getRawClass()); JsonDeserializer localJsonDeserializer = paramDeserializationContext.getDeserializerProvider().findValueDeserializer(paramDeserializationContext.getConfig(), localJavaType, this._property); this._deserializers.put(paramString, localJsonDeserializer); label125: monitorexit; return localJsonDeserializer; }
public JsonDeserializer<?> createCollectionLikeDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, CollectionLikeType paramCollectionLikeType, BeanProperty paramBeanProperty) throws JsonMappingException { CollectionLikeType localCollectionLikeType1 = (CollectionLikeType)mapAbstractType(paramDeserializationConfig, paramCollectionLikeType); BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectClassAnnotations(localCollectionLikeType1.getRawClass()); JsonDeserializer localJsonDeserializer1 = findDeserializerFromAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), paramBeanProperty); if (localJsonDeserializer1 != null) return localJsonDeserializer1; CollectionLikeType localCollectionLikeType2 = (CollectionLikeType)modifyTypeByAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), localCollectionLikeType1, null); JavaType localJavaType = localCollectionLikeType2.getContentType(); JsonDeserializer localJsonDeserializer2 = (JsonDeserializer)localJavaType.getValueHandler(); TypeDeserializer localTypeDeserializer = (TypeDeserializer)localJavaType.getTypeHandler(); if (localTypeDeserializer == null) localTypeDeserializer = findTypeDeserializer(paramDeserializationConfig, localJavaType, paramBeanProperty); return _findCustomCollectionLikeDeserializer(localCollectionLikeType2, paramDeserializationConfig, paramDeserializerProvider, localBasicBeanDescription, paramBeanProperty, localTypeDeserializer, localJsonDeserializer2); }
public JsonDeserializer<?> createEnumDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, JavaType paramJavaType, BeanProperty paramBeanProperty) throws JsonMappingException { BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectForCreation(paramJavaType); JsonDeserializer localJsonDeserializer1 = findDeserializerFromAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), paramBeanProperty); if (localJsonDeserializer1 != null) return localJsonDeserializer1; Class localClass = paramJavaType.getRawClass(); JsonDeserializer localJsonDeserializer2 = _findCustomEnumDeserializer(localClass, paramDeserializationConfig, localBasicBeanDescription, paramBeanProperty); if (localJsonDeserializer2 != null) return localJsonDeserializer2; Iterator localIterator = localBasicBeanDescription.getFactoryMethods().iterator(); while (localIterator.hasNext()) { AnnotatedMethod localAnnotatedMethod = (AnnotatedMethod)localIterator.next(); if (!paramDeserializationConfig.getAnnotationIntrospector().hasCreatorAnnotation(localAnnotatedMethod)) continue; if ((localAnnotatedMethod.getParameterCount() == 1) && (localAnnotatedMethod.getRawType().isAssignableFrom(localClass))) return EnumDeserializer.deserializerForCreator(paramDeserializationConfig, localClass, localAnnotatedMethod); throw new IllegalArgumentException("Unsuitable method (" + localAnnotatedMethod + ") decorated with @JsonCreator (for Enum type " + localClass.getName() + ")"); } return new EnumDeserializer(constructEnumResolver(localClass, paramDeserializationConfig)); }
public JsonDeserializer<?> createMapLikeDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, MapLikeType paramMapLikeType, BeanProperty paramBeanProperty) throws JsonMappingException { MapLikeType localMapLikeType1 = (MapLikeType)mapAbstractType(paramDeserializationConfig, paramMapLikeType); BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectForCreation(localMapLikeType1); JsonDeserializer localJsonDeserializer1 = findDeserializerFromAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), paramBeanProperty); if (localJsonDeserializer1 != null) return localJsonDeserializer1; MapLikeType localMapLikeType2 = (MapLikeType)modifyTypeByAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), localMapLikeType1, null); JavaType localJavaType1 = localMapLikeType2.getKeyType(); JavaType localJavaType2 = localMapLikeType2.getContentType(); JsonDeserializer localJsonDeserializer2 = (JsonDeserializer)localJavaType2.getValueHandler(); KeyDeserializer localKeyDeserializer = (KeyDeserializer)localJavaType1.getValueHandler(); if (localKeyDeserializer == null) localKeyDeserializer = paramDeserializerProvider.findKeyDeserializer(paramDeserializationConfig, localJavaType1, paramBeanProperty); TypeDeserializer localTypeDeserializer = (TypeDeserializer)localJavaType2.getTypeHandler(); if (localTypeDeserializer == null) localTypeDeserializer = findTypeDeserializer(paramDeserializationConfig, localJavaType2, paramBeanProperty); return _findCustomMapLikeDeserializer(localMapLikeType2, paramDeserializationConfig, paramDeserializerProvider, localBasicBeanDescription, paramBeanProperty, localKeyDeserializer, localTypeDeserializer, localJsonDeserializer2); }
protected JsonDeserializer<Object> findStdBeanDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, JavaType paramJavaType, BeanProperty paramBeanProperty) throws JsonMappingException { JsonDeserializer localJsonDeserializer1 = (JsonDeserializer)_simpleDeserializers.get(paramJavaType); if (localJsonDeserializer1 != null) return localJsonDeserializer1; if (AtomicReference.class.isAssignableFrom(paramJavaType.getRawClass())) { JavaType[] arrayOfJavaType = paramDeserializationConfig.getTypeFactory().findTypeParameters(paramJavaType, AtomicReference.class); if ((arrayOfJavaType == null) || (arrayOfJavaType.length < 1)); for (JavaType localJavaType = TypeFactory.unknownType(); ; localJavaType = arrayOfJavaType[0]) return new StdDeserializer.AtomicReferenceDeserializer(localJavaType, paramBeanProperty); } JsonDeserializer localJsonDeserializer2 = this.optionalHandlers.findDeserializer(paramJavaType, paramDeserializationConfig, paramDeserializerProvider); if (localJsonDeserializer2 != null) return localJsonDeserializer2; return null; }
protected Object handlePolymorphic(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Object paramObject, TokenBuffer paramTokenBuffer) throws IOException, JsonProcessingException { JsonDeserializer localJsonDeserializer = _findSubclassDeserializer(paramDeserializationContext, paramObject, paramTokenBuffer); if (localJsonDeserializer != null) { if (paramTokenBuffer != null) { paramTokenBuffer.writeEndObject(); JsonParser localJsonParser = paramTokenBuffer.asParser(); localJsonParser.nextToken(); paramObject = localJsonDeserializer.deserialize(localJsonParser, paramDeserializationContext, paramObject); } if (paramJsonParser != null) paramObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext, paramObject); return paramObject; } if (paramTokenBuffer != null) paramObject = handleUnknownProperties(paramDeserializationContext, paramObject, paramTokenBuffer); if (paramJsonParser != null) paramObject = deserialize(paramJsonParser, paramDeserializationContext, paramObject); return paramObject; }
public JsonDeserializer<Object> findValueDeserializer(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType, BeanProperty paramBeanProperty) throws JsonMappingException { JsonDeserializer localJsonDeserializer1 = _findCachedDeserializer(paramJavaType); if (localJsonDeserializer1 != null) { if ((localJsonDeserializer1 instanceof ContextualDeserializer)) localJsonDeserializer1 = ((ContextualDeserializer)localJsonDeserializer1).createContextual(paramDeserializationConfig, paramBeanProperty); return localJsonDeserializer1; } JsonDeserializer localJsonDeserializer2 = _createAndCacheValueDeserializer(paramDeserializationConfig, paramJavaType, paramBeanProperty); if (localJsonDeserializer2 == null) localJsonDeserializer2 = _handleUnknownValueDeserializer(paramJavaType); if ((localJsonDeserializer2 instanceof ContextualDeserializer)) localJsonDeserializer2 = ((ContextualDeserializer)localJsonDeserializer2).createContextual(paramDeserializationConfig, paramBeanProperty); return localJsonDeserializer2; }
public boolean hasValueDeserializerFor(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType) { Object localObject = _findCachedDeserializer(paramJavaType); if (localObject == null); try { JsonDeserializer localJsonDeserializer = _createAndCacheValueDeserializer(paramDeserializationConfig, paramJavaType, null); localObject = localJsonDeserializer; int i = 0; if (localObject != null) i = 1; return i; } catch (Exception localException) { } return false; }
private final Collection<Object> handleNonArray(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<Object> paramCollection) throws IOException, JsonProcessingException { if (!paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) throw paramDeserializationContext.mappingException(this._collectionType.getRawClass()); JsonDeserializer localJsonDeserializer = this._valueDeserializer; TypeDeserializer localTypeDeserializer = this._valueTypeDeserializer; Object localObject; if (paramJsonParser.getCurrentToken() == JsonToken.VALUE_NULL) localObject = null; while (true) { paramCollection.add(localObject); return paramCollection; if (localTypeDeserializer == null) { localObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext); continue; } localObject = localJsonDeserializer.deserializeWithType(paramJsonParser, paramDeserializationContext, localTypeDeserializer); } }
private Collection<String> deserializeUsingCustom(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<String> paramCollection) throws IOException, JsonProcessingException { JsonDeserializer localJsonDeserializer = this._valueDeserializer; JsonToken localJsonToken = paramJsonParser.nextToken(); if (localJsonToken != JsonToken.END_ARRAY) { if (localJsonToken == JsonToken.VALUE_NULL); for (Object localObject = null; ; localObject = (String)localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext)) { paramCollection.add(localObject); break; } } return (Collection<String>)paramCollection; }
private final Collection<String> handleNonArray(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<String> paramCollection) throws IOException, JsonProcessingException { if (!paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) throw paramDeserializationContext.mappingException(this._collectionType.getRawClass()); JsonDeserializer localJsonDeserializer = this._valueDeserializer; if (paramJsonParser.getCurrentToken() == JsonToken.VALUE_NULL) { localObject = null; paramCollection.add(localObject); return paramCollection; } if (localJsonDeserializer == null); for (Object localObject = paramJsonParser.getText(); ; localObject = (String)localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext)) break; }
public JsonDeserializer<Object> buildBeanDeserializer(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType, BasicBeanDescription paramBasicBeanDescription, BeanProperty paramBeanProperty) throws JsonMappingException { BeanDeserializerBuilder localBeanDeserializerBuilder = constructBeanDeserializerBuilder(paramBasicBeanDescription); localBeanDeserializerBuilder.setCreators(findDeserializerCreators(paramDeserializationConfig, paramBasicBeanDescription)); addBeanProps(paramDeserializationConfig, paramBasicBeanDescription, localBeanDeserializerBuilder); addReferenceProperties(paramDeserializationConfig, paramBasicBeanDescription, localBeanDeserializerBuilder); if (this._factoryConfig.hasDeserializerModifiers()) { Iterator localIterator2 = this._factoryConfig.deserializerModifiers().iterator(); while (localIterator2.hasNext()) localBeanDeserializerBuilder = ((BeanDeserializerModifier)localIterator2.next()).updateBuilder(paramDeserializationConfig, paramBasicBeanDescription, localBeanDeserializerBuilder); } JsonDeserializer localJsonDeserializer = localBeanDeserializerBuilder.build(paramBeanProperty); if (this._factoryConfig.hasDeserializerModifiers()) { Iterator localIterator1 = this._factoryConfig.deserializerModifiers().iterator(); while (localIterator1.hasNext()) localJsonDeserializer = ((BeanDeserializerModifier)localIterator1.next()).modifyDeserializer(paramDeserializationConfig, paramBasicBeanDescription, localJsonDeserializer); } return localJsonDeserializer; }
protected SettableAnyProperty constructAnySetter(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription, AnnotatedMethod paramAnnotatedMethod) throws JsonMappingException { if (paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) paramAnnotatedMethod.fixAccess(); JavaType localJavaType1 = paramBasicBeanDescription.bindingsForBeanType().resolveType(paramAnnotatedMethod.getParameterType(1)); BeanProperty.Std localStd = new BeanProperty.Std(paramAnnotatedMethod.getName(), localJavaType1, paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedMethod); JavaType localJavaType2 = resolveType(paramDeserializationConfig, paramBasicBeanDescription, localJavaType1, paramAnnotatedMethod, localStd); JsonDeserializer localJsonDeserializer = findDeserializerFromAnnotation(paramDeserializationConfig, paramAnnotatedMethod, localStd); if (localJsonDeserializer != null) { SettableAnyProperty localSettableAnyProperty = new SettableAnyProperty(localStd, paramAnnotatedMethod, localJavaType2); localSettableAnyProperty.setValueDeserializer(localJsonDeserializer); return localSettableAnyProperty; } return new SettableAnyProperty(localStd, paramAnnotatedMethod, modifyTypeByAnnotation(paramDeserializationConfig, paramAnnotatedMethod, localJavaType2, localStd.getName())); }
protected SettableBeanProperty constructSettableProperty(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription, String paramString, AnnotatedField paramAnnotatedField) throws JsonMappingException { if (paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) paramAnnotatedField.fixAccess(); JavaType localJavaType1 = paramBasicBeanDescription.bindingsForBeanType().resolveType(paramAnnotatedField.getGenericType()); BeanProperty.Std localStd = new BeanProperty.Std(paramString, localJavaType1, paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedField); JavaType localJavaType2 = resolveType(paramDeserializationConfig, paramBasicBeanDescription, localJavaType1, paramAnnotatedField, localStd); if (localJavaType2 != localJavaType1) localStd = localStd.withType(localJavaType2); JsonDeserializer localJsonDeserializer = findDeserializerFromAnnotation(paramDeserializationConfig, paramAnnotatedField, localStd); JavaType localJavaType3 = modifyTypeByAnnotation(paramDeserializationConfig, paramAnnotatedField, localJavaType2, paramString); SettableBeanProperty.FieldProperty localFieldProperty = new SettableBeanProperty.FieldProperty(paramString, localJavaType3, (TypeDeserializer)localJavaType3.getTypeHandler(), paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedField); if (localJsonDeserializer != null) localFieldProperty.setValueDeserializer(localJsonDeserializer); AnnotationIntrospector.ReferenceProperty localReferenceProperty = paramDeserializationConfig.getAnnotationIntrospector().findReferenceType(paramAnnotatedField); if ((localReferenceProperty != null) && (localReferenceProperty.isManagedReference())) localFieldProperty.setManagedReferenceName(localReferenceProperty.getName()); return localFieldProperty; }
protected SettableBeanProperty constructSettableProperty(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription, String paramString, AnnotatedMethod paramAnnotatedMethod) throws JsonMappingException { if (paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) paramAnnotatedMethod.fixAccess(); JavaType localJavaType1 = paramBasicBeanDescription.bindingsForBeanType().resolveType(paramAnnotatedMethod.getParameterType(0)); BeanProperty.Std localStd = new BeanProperty.Std(paramString, localJavaType1, paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedMethod); JavaType localJavaType2 = resolveType(paramDeserializationConfig, paramBasicBeanDescription, localJavaType1, paramAnnotatedMethod, localStd); if (localJavaType2 != localJavaType1) localStd = localStd.withType(localJavaType2); JsonDeserializer localJsonDeserializer = findDeserializerFromAnnotation(paramDeserializationConfig, paramAnnotatedMethod, localStd); JavaType localJavaType3 = modifyTypeByAnnotation(paramDeserializationConfig, paramAnnotatedMethod, localJavaType2, paramString); SettableBeanProperty.MethodProperty localMethodProperty = new SettableBeanProperty.MethodProperty(paramString, localJavaType3, (TypeDeserializer)localJavaType3.getTypeHandler(), paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedMethod); if (localJsonDeserializer != null) localMethodProperty.setValueDeserializer(localJsonDeserializer); AnnotationIntrospector.ReferenceProperty localReferenceProperty = paramDeserializationConfig.getAnnotationIntrospector().findReferenceType(paramAnnotatedMethod); if ((localReferenceProperty != null) && (localReferenceProperty.isManagedReference())) localMethodProperty.setManagedReferenceName(localReferenceProperty.getName()); return localMethodProperty; }
@Override public JsonDeserializer<?> findBeanDeserializer(JavaType type, DeserializationConfig config, DeserializerProvider provider, BeanDescription beanDesc, BeanProperty property) throws JsonMappingException { // Check if we have to find a deserializer for the root level. if (type.getRawClass() == JsonRootWrapper.class) { Class contentType = type.containedType(0).getRawClass(); // Check if a deserializer already exists if (deserializers.containsKey(contentType)) { return deserializers.get(contentType); } else { // Create the new deserializer and cache it. JsonRootWrapperDeserializer deserializer = new JsonRootWrapperDeserializer(contentType); deserializers.put(contentType, deserializer); return deserializer; } } return null; }
@Test @RoxableTest(key = "ee1d7bd61b13") public void jsonRootDeserializerShouldReturnExistingDeserializerIfAny() { JavaType type = new TestType(JsonRootWrapper.class, Integer.class); JsonRootWrapperDeserializer expectedDeserializer = new JsonRootWrapperDeserializer(type.containedType(0).getRawClass()); JsonDeserializer actualDeserializer = null; Whitebox.setInternalState(jsonRootDeserializer, "deserializers", deserializers); when(deserializers.containsKey(type.containedType(0).getRawClass())).thenReturn(Boolean.TRUE); when(deserializers.get(type.containedType(0).getRawClass())).thenReturn(expectedDeserializer); try { actualDeserializer = jsonRootDeserializer.findBeanDeserializer(type, null, null, null, null); } catch (JsonMappingException ex) { fail("Unexpected exception when finding Bean Deserializer"); } assertEquals(expectedDeserializer, actualDeserializer); }
@Override public Class<? extends JsonDeserializer<?>> findDeserializer(Annotated a) { /* 21-May-2009, tatu: Slight change; primary annotation is now * @JsonDeserialize; @JsonUseDeserializer is deprecated */ JsonDeserialize ann = a.getAnnotation(JsonDeserialize.class); if (ann != null) { Class<? extends JsonDeserializer<?>> deserClass = ann.using(); if (deserClass != JsonDeserializer.None.class) { return deserClass; } } // 31-Jan-2010, tatus: @JsonUseDeserializer removed as of 1.5 return null; }
private final Collection<String> handleNonArray(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<String> paramCollection) { if (!paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) throw paramDeserializationContext.mappingException(this._collectionType.getRawClass()); JsonDeserializer localJsonDeserializer = this._valueDeserializer; Object localObject; if (paramJsonParser.getCurrentToken() == JsonToken.VALUE_NULL) localObject = null; while (true) { paramCollection.add(localObject); return paramCollection; if (localJsonDeserializer == null) localObject = paramJsonParser.getText(); else localObject = (String)localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext); } }
@Override public List<Map<Term, String>> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { if (jp.getCurrentToken() == JsonToken.START_ARRAY) { JsonDeserializer<Object> deserializer = ctxt.getDeserializerProvider().findTypedValueDeserializer(ctxt.getConfig(), ctxt.constructType(List.class),null); List<Map<String, String>> verbatimTerms = (List<Map<String, String>>) deserializer.deserialize(jp, ctxt); List<Map<Term, String>> interpretedTerms = Lists.newArrayList(); for (Map<String, String> verbExtension : verbatimTerms) { Map<Term, String> extension = new HashMap<Term, String>(); for (Entry<String, String> entry : verbExtension.entrySet()) { Term term = termFactory.findTerm(entry.getKey()); if (term == null && ctxt.getConfig().isEnabled(Feature.FAIL_ON_UNKNOWN_PROPERTIES)) { throw ctxt.mappingException("Term not found " + entry.getKey()); } extension.put(term, entry.getValue()); } interpretedTerms.add(extension); } return interpretedTerms; } throw ctxt.mappingException("Expected JSON String"); }
public final JsonDeserializer<?> findMapDeserializer(MapType paramMapType, DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, BeanDescription paramBeanDescription, BeanProperty paramBeanProperty, KeyDeserializer paramKeyDeserializer, TypeDeserializer paramTypeDeserializer, JsonDeserializer<?> paramJsonDeserializer) { Class localClass = paramMapType.getRawClass(); if (dh.class.isAssignableFrom(localClass)) { dx.class.isAssignableFrom(localClass); cq.class.isAssignableFrom(localClass); return new e(paramMapType, paramKeyDeserializer, paramTypeDeserializer, a(paramJsonDeserializer, paramDeserializationConfig, paramDeserializerProvider, paramBeanProperty, paramMapType)); } if (hs.class.isAssignableFrom(localClass)) { ep.class.isAssignableFrom(localClass); jb.class.isAssignableFrom(localClass); kf.class.isAssignableFrom(localClass); } return null; }
protected SettableBeanProperty constructSettableProperty(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription, String paramString, AnnotatedMethod paramAnnotatedMethod) { if (paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) paramAnnotatedMethod.fixAccess(); JavaType localJavaType1 = paramBasicBeanDescription.bindingsForBeanType().resolveType(paramAnnotatedMethod.getParameterType(0)); BeanProperty.Std localStd = new BeanProperty.Std(paramString, localJavaType1, paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedMethod); JavaType localJavaType2 = resolveType(paramDeserializationConfig, paramBasicBeanDescription, localJavaType1, paramAnnotatedMethod, localStd); if (localJavaType2 != localJavaType1) localStd = localStd.withType(localJavaType2); JsonDeserializer localJsonDeserializer = findDeserializerFromAnnotation(paramDeserializationConfig, paramAnnotatedMethod, localStd); JavaType localJavaType3 = modifyTypeByAnnotation(paramDeserializationConfig, paramAnnotatedMethod, localJavaType2, paramString); Object localObject = new SettableBeanProperty.MethodProperty(paramString, localJavaType3, (TypeDeserializer)localJavaType3.getTypeHandler(), paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedMethod); if (localJsonDeserializer != null) localObject = ((SettableBeanProperty)localObject).withValueDeserializer(localJsonDeserializer); AnnotationIntrospector.ReferenceProperty localReferenceProperty = paramDeserializationConfig.getAnnotationIntrospector().findReferenceType(paramAnnotatedMethod); if ((localReferenceProperty != null) && (localReferenceProperty.isManagedReference())) ((SettableBeanProperty)localObject).setManagedReferenceName(localReferenceProperty.getName()); return localObject; }
private CustomDeserializerFactory createFactory() { final CustomDeserializerFactory factory = new CustomDeserializerFactory(); for (final Map.Entry<Class, JsonDeserializer> mapping : mappings.entrySet()) { factory.addSpecificMapping(mapping.getKey(), mapping.getValue()); } return factory; }
@Override @SuppressWarnings("unchecked") public JsonDeserializer<Object> createContextual(DeserializationConfig config, BeanProperty property) throws JsonMappingException { final Class<?> rawClass = property.getType().getRawClass(); final Class<?> componentType = rawClass.getComponentType(); if (componentType == null || !componentType.isEnum()) { throw new JsonMappingException("Pick list Enum array expected for " + rawClass); } return new MultiSelectPicklistDeserializer((Class<? extends Enum>) componentType); }
@Override public JsonDeserializer<?> createCollectionDeserializer(final DeserializationConfig config, final DeserializerProvider p, final CollectionType type, final BeanProperty property) throws JsonMappingException { if (CollectionPage.class.equals(type.getRawClass())) { final JsonDeserializer<Object> contentDeserializer = type.getContentType().getValueHandler(); return new CollectionPageDeserializer(type, contentDeserializer); } return nonCollectionPageStrategy.createCollectionDeserializer(config, p, type, property); }
@Override public JsonDeserializer<Object> createBeanDeserializer(final DeserializationConfig config, final DeserializerProvider p, final JavaType type, final BeanProperty property) throws JsonMappingException { return nonCollectionPageStrategy.createBeanDeserializer(config, p, type, property); }
@Override public JsonDeserializer<?> createArrayDeserializer(final DeserializationConfig config, final DeserializerProvider p, final ArrayType type, final BeanProperty property) throws JsonMappingException { return nonCollectionPageStrategy.createArrayDeserializer(config, p, type, property); }
@Override public JsonDeserializer<?> createCollectionLikeDeserializer(final DeserializationConfig config, final DeserializerProvider p, final CollectionLikeType type, final BeanProperty property) throws JsonMappingException { return nonCollectionPageStrategy.createCollectionLikeDeserializer(config, p, type, property); }
@Override public JsonDeserializer<?> createEnumDeserializer(final DeserializationConfig config, final DeserializerProvider p, final JavaType type, final BeanProperty property) throws JsonMappingException { return nonCollectionPageStrategy.createEnumDeserializer(config, p, type, property); }
@Override public JsonDeserializer<?> createMapDeserializer(final DeserializationConfig config, final DeserializerProvider p, final MapType type, final BeanProperty property) throws JsonMappingException { return nonCollectionPageStrategy.createMapDeserializer(config, p, type, property); }
@Override public JsonDeserializer<?> createMapLikeDeserializer(final DeserializationConfig config, final DeserializerProvider p, final MapLikeType type, final BeanProperty property) throws JsonMappingException { return nonCollectionPageStrategy.createMapLikeDeserializer(config, p, type, property); }
@Override public JsonDeserializer<?> createTreeDeserializer(final DeserializationConfig config, final DeserializerProvider p, final JavaType type, final BeanProperty property) throws JsonMappingException { return nonCollectionPageStrategy.createTreeDeserializer(config, p, type, property); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void afterPropertiesSet() throws Exception { if (jsonSerializers != null) { if (logger.isDebugEnabled()) { logger.debug("Setting up Json Module serializers"); } for (JsonSerializer aSerializer : jsonSerializers) { addSerializer(aSerializer); } } if (jsonDeserializers != null) { if (logger.isDebugEnabled()) { logger.debug("Setting up Json Module deserializers"); } for (Entry<String, JsonDeserializer> aDeserializer : jsonDeserializers.entrySet()) { Class theDeserializer = Class.forName(aDeserializer.getKey()); addDeserializer(theDeserializer, aDeserializer.getValue()); } } }
private final Object _deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext) throws IOException, JsonProcessingException { if (paramJsonParser.getCurrentToken() != JsonToken.START_OBJECT) throw paramDeserializationContext.wrongTokenException(paramJsonParser, JsonToken.START_OBJECT, "need JSON Object to contain As.WRAPPER_OBJECT type information for class " + baseTypeName()); if (paramJsonParser.nextToken() != JsonToken.FIELD_NAME) throw paramDeserializationContext.wrongTokenException(paramJsonParser, JsonToken.FIELD_NAME, "need JSON String that contains type id (for subtype of " + baseTypeName() + ")"); JsonDeserializer localJsonDeserializer = _findDeserializer(paramDeserializationContext, paramJsonParser.getText()); paramJsonParser.nextToken(); Object localObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext); if (paramJsonParser.nextToken() != JsonToken.END_OBJECT) throw paramDeserializationContext.wrongTokenException(paramJsonParser, JsonToken.END_OBJECT, "expected closing END_OBJECT after type information and deserialized value"); return localObject; }
public <T> SimpleModule addDeserializer(Class<T> paramClass, JsonDeserializer<? extends T> paramJsonDeserializer) { if (this._deserializers == null) this._deserializers = new SimpleDeserializers(); this._deserializers.addDeserializer(paramClass, paramJsonDeserializer); return this; }