Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.jackson.databind.util;
 
 
 
Container class that can be used to wrap any Object instances (including nulls), and will serialize embedded in JSONP wrapping.

Author(s):
tatu
See also:
JSONWrappedObject
public class JSONPObject
    implements JsonSerializable
{
    
JSONP function name to use for serialization
    protected final String _function;
    
    
Value to be serialized as JSONP padded; can be null.
    protected final Object _value;

    
Optional static type to use for serialization; if null, runtime type is used. Can be used to specify declared type which defines serializer to use, as well as aspects of extra type information to include (if any).
    protected final JavaType _serializationType;
    public JSONPObject(String functionObject value) {
        this(functionvalue, (JavaTypenull);
    }
    public JSONPObject(String functionObject valueJavaType asType)
    {
         = function;
         = value;
         = asType;
    }
    
    /*
    /**********************************************************
    /* JsonSerializable(WithType) implementation
    /**********************************************************
     */
    
//  @Override
    public void serializeWithType(JsonGenerator jgenSerializerProvider providerTypeSerializer typeSer)
            throws IOExceptionJsonProcessingException
    {
        // No type for JSONP wrapping: value serializer will handle typing for value:
        serialize(jgenprovider);
    }
//  @Override
    public void serialize(JsonGenerator jgenSerializerProvider provider)
            throws IOExceptionJsonProcessingException
    {
        // First, wrapping:
        jgen.writeRaw();
        jgen.writeRaw('(');
        if ( == null) {
            provider.defaultSerializeNull(jgen);
        } else if ( != null) {
            provider.findTypedValueSerializer(truenull).serialize(jgenprovider);
        } else {
            Class<?> cls = .getClass();
            provider.findTypedValueSerializer(clstruenull).serialize(jgenprovider);
        }
        jgen.writeRaw(')');
    }
    /*
    /**************************************************************
    /* Accessors
    /**************************************************************
     */
    
    public String getFunction() { return ; }
    public Object getValue() { return ; }
    public JavaType getSerializationType() { return ; }
New to GrepCode? Check out our FAQ X