com.fasterxml.jackson.databind.jsonFormatVisitors.JsonMapFormatVisitor Java Examples

The following examples show how to use com.fasterxml.jackson.databind.jsonFormatVisitors.JsonMapFormatVisitor. 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: MultimapSerializer.java    From jackson-datatypes-collections with Apache License 2.0 6 votes vote down vote up
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
    throws JsonMappingException
{
    JsonMapFormatVisitor v2 = (visitor == null) ? null : visitor.expectMapFormat(typeHint);        
    if (v2 != null) {
        v2.keyFormat(_keySerializer, _type.getKeyType());
        JsonSerializer<?> valueSer = _valueSerializer;
        final JavaType vt = _type.getContentType();
        final SerializerProvider prov = visitor.getProvider();
        if (valueSer == null) {
            valueSer = _findAndAddDynamic(prov, vt);
        }
        final JsonSerializer<?> valueSer2 = valueSer;
        v2.valueFormat(new JsonFormatVisitable() {
            final JavaType arrayType = prov.getTypeFactory().constructArrayType(vt);
            @Override
            public void acceptJsonFormatVisitor(
                    JsonFormatVisitorWrapper v3, JavaType hint3)
                throws JsonMappingException
            {
                JsonArrayFormatVisitor v4 = v3.expectArrayFormat(arrayType);
                if (v4 != null) {
                    v4.itemsFormat(valueSer2, vt);
                }
            }
        }, vt);
    }
}
 
Example #2
Source File: MapSerializer.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
    throws JsonMappingException
{
    JsonMapFormatVisitor v2 = visitor.expectMapFormat(typeHint);        
    if (v2 != null) {
        v2.keyFormat(_keySerializer, _keyType);
        JsonSerializer<?> valueSer = _valueSerializer;
        if (valueSer == null) {
            valueSer = _findAndAddDynamic(_dynamicValueSerializers,
                        _valueType, visitor.getProvider());
        }
        v2.valueFormat(valueSer, _valueType);
    }
}
 
Example #3
Source File: FieldDocumentationVisitorWrapper.java    From spring-auto-restdocs with Apache License 2.0 4 votes vote down vote up
@Override
public JsonMapFormatVisitor expectMapFormat(JavaType type) throws JsonMappingException {
    addFieldIfPresent("Map");
    return new JsonMapFormatVisitor.Base(provider);
}