com.fasterxml.jackson.databind.ser.std.MapSerializer Java Examples

The following examples show how to use com.fasterxml.jackson.databind.ser.std.MapSerializer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnyGetterWriter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public AnyGetterWriter(BeanProperty property,
        AnnotatedMember accessor, JsonSerializer<?> serializer)
{
    _accessor = accessor;
    _property = property;
    _serializer = (JsonSerializer<Object>) serializer;
    if (serializer instanceof MapSerializer) {
        _mapSerializer = (MapSerializer) serializer;
    }
}
 
Example #2
Source File: AnyGetterWriter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void resolve(SerializerProvider provider) throws JsonMappingException
{
    // 05-Sep-2013, tatu: I _think_ this can be considered a primary property...
    if (_serializer instanceof ContextualSerializer) {
        JsonSerializer<?> ser = provider.handlePrimaryContextualization(_serializer, _property);
        _serializer = (JsonSerializer<Object>) ser;
        if (ser instanceof MapSerializer) {
            _mapSerializer = (MapSerializer) ser;
        }
    }
}
 
Example #3
Source File: TableSerializer.java    From jackson-datatypes-collections with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings( "unchecked" )
protected TableSerializer(final TableSerializer src,
        final BeanProperty property,
        final TypeFactory typeFactory,
        final JsonSerializer<?> rowKeySerializer,
        final JsonSerializer<?> columnKeySerializer,
        final TypeSerializer valueTypeSerializer,
        final JsonSerializer<?> valueSerializer)
{
    super(src, property);
    _type = src._type;
    _rowSerializer = (JsonSerializer<Object>) rowKeySerializer;
    _columnSerializer = (JsonSerializer<Object>) columnKeySerializer;
    _valueTypeSerializer = valueTypeSerializer;
    _valueSerializer = (JsonSerializer<Object>) valueSerializer;
    
    final MapType columnAndValueType = typeFactory.constructMapType(Map.class,
            _type.containedTypeOrUnknown(1), _type.containedTypeOrUnknown(2));

    JsonSerializer<?> columnAndValueSerializer = 
            MapSerializer.construct((Set<String>) null,
                                    columnAndValueType,
                                    false,
                                    _valueTypeSerializer,
                                    _columnSerializer,
                                    _valueSerializer,
                                    null);

    final MapType rowMapType = typeFactory.constructMapType(Map.class,
            _type.containedTypeOrUnknown(0), columnAndValueType);
    _rowMapSerializer =
            MapSerializer.construct((Set<String>) null,
                                    rowMapType,
                                    false,
                                    null,
                                    _rowSerializer,
                                    (JsonSerializer<Object>) columnAndValueSerializer,
                                    null);
}
 
Example #4
Source File: ObjectMapperUtil.java    From endpoints-java with Apache License 2.0 5 votes vote down vote up
@Override
public JsonSerializer<?> modifyMapSerializer(SerializationConfig config, MapType valueType,
    BeanDescription beanDesc, JsonSerializer<?> serializer) {
  if (serializer instanceof MapSerializer) {
    // TODO: We should probably be propagating the NON_EMPTY inclusion here, but it's breaking
    // discovery.
    return new DeepEmptyCheckingSerializer<>(serializer);
  }
  return serializer;
}