Class FastJsonProvider
- java.lang.Object
-
- com.alibaba.fastjson.support.jaxrs.FastJsonProvider
-
- All Implemented Interfaces:
javax.ws.rs.ext.MessageBodyReader<Object>,javax.ws.rs.ext.MessageBodyWriter<Object>
@Provider @Consumes("*/*") @Produces("*/*") public class FastJsonProvider extends Object implements javax.ws.rs.ext.MessageBodyReader<Object>, javax.ws.rs.ext.MessageBodyWriter<Object>Fastjson for JAX-RS Provider.- Since:
- 1.2.9
- Author:
- smallnest, VictorZeng
- See Also:
MessageBodyReader,MessageBodyWriter
-
-
Field Summary
Fields Modifier and Type Field Description static Class<?>[]DEFAULT_UNREADABLESThese are classes that we never use for reading (never try to deserialize instances of these types).static Class<?>[]DEFAULT_UNWRITABLESThese are classes that we never use for writing (never try to serialize instances of these types).
-
Constructor Summary
Constructors Constructor Description FastJsonProvider()Can serialize/deserialize all types.FastJsonProvider(Class<?>[] clazzes)Only serialize/deserialize all types in clazzes.FastJsonProvider(String charset)Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description CharsetgetCharset()Deprecated.StringgetDateFormat()Deprecated.FastJsonConfiggetFastJsonConfig()SerializerFeature[]getFeatures()Deprecated.SerializeFilter[]getFilters()Deprecated.longgetSize(Object t, Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)Method that JAX-RS container calls to try to figure out serialized length of given value. always return -1 to denote "not known".booleanisReadable(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)Method that JAX-RS container calls to try to check whether values of given type (and media type) can be deserialized by this provider.booleanisWriteable(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)Method that JAX-RS container calls to try to check whether given value (of specified type) can be serialized by this provider.ObjectreadFrom(Class<Object> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String,String> httpHeaders, InputStream entityStream)Method that JAX-RS container calls to deserialize given value.voidsetCharset(Charset charset)Deprecated.voidsetDateFormat(String dateFormat)Deprecated.voidsetFastJsonConfig(FastJsonConfig fastJsonConfig)voidsetFeatures(SerializerFeature... features)Deprecated.voidsetFilters(SerializeFilter... filters)Deprecated.FastJsonProvidersetPretty(boolean p)Set pretty formatvoidwriteTo(Object obj, Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders, OutputStream entityStream)Method that JAX-RS container calls to serialize given value.
-
-
-
Field Detail
-
DEFAULT_UNREADABLES
public static final Class<?>[] DEFAULT_UNREADABLES
These are classes that we never use for reading (never try to deserialize instances of these types).
-
DEFAULT_UNWRITABLES
public static final Class<?>[] DEFAULT_UNWRITABLES
These are classes that we never use for writing (never try to serialize instances of these types).
-
-
Constructor Detail
-
FastJsonProvider
public FastJsonProvider()
Can serialize/deserialize all types.
-
FastJsonProvider
public FastJsonProvider(Class<?>[] clazzes)
Only serialize/deserialize all types in clazzes.
-
FastJsonProvider
@Deprecated public FastJsonProvider(String charset)
Deprecated.Instantiates a new Fast json provider.- Parameters:
charset- the charset- See Also:
FastJsonConfig.setCharset(Charset)
-
-
Method Detail
-
getFastJsonConfig
public FastJsonConfig getFastJsonConfig()
- Returns:
- the fastJsonConfig.
- Since:
- 1.2.11
-
setFastJsonConfig
public void setFastJsonConfig(FastJsonConfig fastJsonConfig)
- Parameters:
fastJsonConfig- the fastJsonConfig to set.- Since:
- 1.2.11
-
setPretty
public FastJsonProvider setPretty(boolean p)
Set pretty format
-
getCharset
@Deprecated public Charset getCharset()
Deprecated.Gets charset.- Returns:
- the charset
- See Also:
FastJsonConfig.getCharset()
-
setCharset
@Deprecated public void setCharset(Charset charset)
Deprecated.Sets charset.- Parameters:
charset- the charset- See Also:
FastJsonConfig.setCharset(Charset)
-
getDateFormat
@Deprecated public String getDateFormat()
Deprecated.Gets date format.- Returns:
- the date format
- See Also:
FastJsonConfig.getDateFormat()
-
setDateFormat
@Deprecated public void setDateFormat(String dateFormat)
Deprecated.Sets date format.- Parameters:
dateFormat- the date format- See Also:
FastJsonConfig.setDateFormat(String)
-
getFeatures
@Deprecated public SerializerFeature[] getFeatures()
Deprecated.Get features serializer feature [].- Returns:
- the serializer feature []
- See Also:
FastJsonConfig.getFeatures()
-
setFeatures
@Deprecated public void setFeatures(SerializerFeature... features)
Deprecated.Sets features.- Parameters:
features- the features- See Also:
FastJsonConfig.setFeatures(Feature...)
-
getFilters
@Deprecated public SerializeFilter[] getFilters()
Deprecated.Get filters serialize filter [].- Returns:
- the serialize filter []
- See Also:
FastJsonConfig.getSerializeFilters()
-
setFilters
@Deprecated public void setFilters(SerializeFilter... filters)
Deprecated.Sets filters.- Parameters:
filters- the filters- See Also:
FastJsonConfig.setSerializeFilters(SerializeFilter...)
-
isWriteable
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
Method that JAX-RS container calls to try to check whether given value (of specified type) can be serialized by this provider.- Specified by:
isWriteablein interfacejavax.ws.rs.ext.MessageBodyWriter<Object>
-
getSize
public long getSize(Object t, Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
Method that JAX-RS container calls to try to figure out serialized length of given value. always return -1 to denote "not known".- Specified by:
getSizein interfacejavax.ws.rs.ext.MessageBodyWriter<Object>
-
writeTo
public void writeTo(Object obj, Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders, OutputStream entityStream) throws IOException, javax.ws.rs.WebApplicationException
Method that JAX-RS container calls to serialize given value.- Specified by:
writeToin interfacejavax.ws.rs.ext.MessageBodyWriter<Object>- Throws:
IOExceptionjavax.ws.rs.WebApplicationException
-
isReadable
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
Method that JAX-RS container calls to try to check whether values of given type (and media type) can be deserialized by this provider.- Specified by:
isReadablein interfacejavax.ws.rs.ext.MessageBodyReader<Object>
-
readFrom
public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String,String> httpHeaders, InputStream entityStream) throws IOException, javax.ws.rs.WebApplicationException
Method that JAX-RS container calls to deserialize given value.- Specified by:
readFromin interfacejavax.ws.rs.ext.MessageBodyReader<Object>- Throws:
IOExceptionjavax.ws.rs.WebApplicationException
-
-