Search in sources :

Example 1 with JsonArrayFormatVisitor

use of com.fasterxml.jackson.databind.jsonFormatVisitors.JsonArrayFormatVisitor in project jackson-databind by FasterXML.

the class ObjectArraySerializer method acceptJsonFormatVisitor.

@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException {
    JsonArrayFormatVisitor arrayVisitor = visitor.expectArrayFormat(typeHint);
    if (arrayVisitor != null) {
        TypeFactory tf = visitor.getProvider().getTypeFactory();
        JavaType contentType = tf.moreSpecificType(_elementType, typeHint.getContentType());
        if (contentType == null) {
            visitor.getProvider().reportBadDefinition(_elementType, "Could not resolve type: " + _elementType);
        }
        JsonSerializer<?> valueSer = _elementSerializer;
        if (valueSer == null) {
            valueSer = visitor.getProvider().findValueSerializer(contentType, _property);
        }
        arrayVisitor.itemsFormat(valueSer, contentType);
    }
}
Also used : JsonArrayFormatVisitor(com.fasterxml.jackson.databind.jsonFormatVisitors.JsonArrayFormatVisitor) TypeFactory(com.fasterxml.jackson.databind.type.TypeFactory)

Aggregations

JsonArrayFormatVisitor (com.fasterxml.jackson.databind.jsonFormatVisitors.JsonArrayFormatVisitor)1 TypeFactory (com.fasterxml.jackson.databind.type.TypeFactory)1