/** * Method called to get the serializer to use for serializing * non-null Map keys. Separation from regular * {@link #findValueSerializer} method is because actual write * method must be different (@link JsonGenerator#writeFieldName}; * but also since behavior for some key types may differ. *<p> * Note that the serializer itself can be called with instances * of any Java object, but not nulls. */ public JsonSerializer<Object> findKeySerializer(JavaType keyType, BeanProperty property) throws JsonMappingException { JsonSerializer<Object> ser = _serializerFactory.createKeySerializer(_config, keyType); // First things first: maybe there are registered custom implementations // if not, use default one: if (ser == null) { if (_keySerializer == null) { ser = StdKeySerializers.getStdKeySerializer(keyType); } else { ser = _keySerializer; } } // 25-Feb-2011, tatu: As per [JACKSON-519], need to ensure contextuality works here, too return _handleContextualResolvable(ser, property); }
public JsonSerializer<Object> createKeySerializer(SerializationConfig paramSerializationConfig, JavaType paramJavaType, JsonSerializer<Object> paramJsonSerializer) { BeanDescription localBeanDescription = paramSerializationConfig.introspectClassAnnotations(paramJavaType.getRawClass()); boolean bool = this._factoryConfig.hasKeySerializers(); Object localObject = null; if (bool) { Iterator localIterator2 = this._factoryConfig.keySerializers().iterator(); JsonSerializer localJsonSerializer; do { if (!localIterator2.hasNext()) break; localJsonSerializer = ((Serializers)localIterator2.next()).findSerializer(paramSerializationConfig, paramJavaType, localBeanDescription); localObject = localJsonSerializer; } while (localJsonSerializer == null); } if (localObject == null) { localObject = paramJsonSerializer; if (paramJsonSerializer == null) localObject = StdKeySerializers.getStdKeySerializer(paramJavaType); } if (this._factoryConfig.hasSerializerModifiers()) { Iterator localIterator1 = this._factoryConfig.serializerModifiers().iterator(); while (localIterator1.hasNext()) localObject = ((BeanSerializerModifier)localIterator1.next()).modifyKeySerializer(paramSerializationConfig, paramJavaType, localBeanDescription, (JsonSerializer)localObject); } return localObject; }