Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.jackson.databind.ser.std;
 
 import java.util.Date;
 
 
Specialized serializer that can be used as the generic key serializer, when serializing java.util.Maps to JSON Objects.
public class StdKeySerializer
    extends StdSerializer<Object>
    final static StdKeySerializer instace = new StdKeySerializer();
    public StdKeySerializer() { super(Object.class); }
    
    @Override
    public void serialize(Object valueJsonGenerator jgenSerializerProvider provider)
        throws IOExceptionJsonGenerationException
    {
        if (value instanceof Date) {
            provider.defaultSerializeDateKey((Datevaluejgen);
        } else {
            jgen.writeFieldName(value.toString());
        }
    }
    @Override
    public JsonNode getSchema(SerializerProvider providerType typeHint)
        throws JsonMappingException
    {
        return createSchemaNode("string");
    }
    
    @Override
    public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitorJavaType typeHint)
    {
    	visitor.expectStringFormat(typeHint);
    }
New to GrepCode? Check out our FAQ X