Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.jackson.databind.ser.std;
 
 
 
This is the special serializer for regular java.lang.Strings.

Since this is one of "native" types, no type information is ever included on serialization (unlike for most scalar types as of 1.5)

public final class StringSerializer
    public StringSerializer() { super(String.class); }

    
For Strings, both null and Empty String qualify for emptiness.
    @Override
    public boolean isEmpty(String value) {
        return (value == null) || (value.length() == 0);
    }
    
    @Override
    public void serialize(String valueJsonGenerator jgenSerializerProvider provider)
        throws IOExceptionJsonGenerationException
    {
        jgen.writeString(value);
    }
    @Override
    public JsonNode getSchema(SerializerProvider providerType typeHint)
    {
        return createSchemaNode("string"true);
    }
    
    @Override
    public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitorJavaType typeHint)
    {
    	visitor.expectStringFormat(typeHint);
    }
New to GrepCode? Check out our FAQ X