Class FastJsonHttpMessageConverter

java.lang.Object
org.springframework.http.converter.AbstractHttpMessageConverter<Object>
com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter
All Implemented Interfaces:
org.springframework.http.converter.GenericHttpMessageConverter<Object>, org.springframework.http.converter.HttpMessageConverter<Object>

public class FastJsonHttpMessageConverter extends org.springframework.http.converter.AbstractHttpMessageConverter<Object> implements org.springframework.http.converter.GenericHttpMessageConverter<Object>
Fastjson for Spring MVC Converter.

Compatible fastjson 1.2.x

Since:
2.0.2
Author:
VictorZeng
See Also:
  • AbstractHttpMessageConverter
  • GenericHttpMessageConverter
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.springframework.http.MediaType
     

    Fields inherited from class org.springframework.http.converter.AbstractHttpMessageConverter

    logger
  • Constructor Summary

    Constructors
    Constructor
    Description
    Can serialize/deserialize all types.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canRead(Type type, Class<?> contextClass, org.springframework.http.MediaType mediaType)
     
    boolean
    canWrite(Type type, Class<?> clazz, org.springframework.http.MediaType mediaType)
     
     
    protected Type
    getType(Type type, Class<?> contextClass)
     
    read(Type type, Class<?> contextClass, org.springframework.http.HttpInputMessage inputMessage)
     
    protected Object
    readInternal(Class<?> clazz, org.springframework.http.HttpInputMessage inputMessage)
     
    void
     
    protected boolean
    supports(Class<?> clazz)
     
    void
    write(Object o, Type type, org.springframework.http.MediaType contentType, org.springframework.http.HttpOutputMessage outputMessage)
     
    protected void
    writeInternal(Object object, org.springframework.http.HttpOutputMessage outputMessage)
     

    Methods inherited from class org.springframework.http.converter.AbstractHttpMessageConverter

    addDefaultHeaders, canRead, canRead, canWrite, canWrite, getContentLength, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, write

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.http.converter.HttpMessageConverter

    canRead, canWrite, getSupportedMediaTypes, getSupportedMediaTypes, read, write
  • Field Details

    • APPLICATION_JAVASCRIPT

      public static final org.springframework.http.MediaType APPLICATION_JAVASCRIPT
  • Constructor Details

    • FastJsonHttpMessageConverter

      public FastJsonHttpMessageConverter()
      Can serialize/deserialize all types.
  • Method Details

    • getFastJsonConfig

      public FastJsonConfig getFastJsonConfig()
      Returns:
      the fastJsonConfig.
    • setFastJsonConfig

      public void setFastJsonConfig(FastJsonConfig fastJsonConfig)
      Parameters:
      fastJsonConfig - the fastJsonConfig to set.
    • supports

      protected boolean supports(Class<?> clazz)
      Specified by:
      supports in class org.springframework.http.converter.AbstractHttpMessageConverter<Object>
    • canRead

      public boolean canRead(Type type, Class<?> contextClass, org.springframework.http.MediaType mediaType)
      Specified by:
      canRead in interface org.springframework.http.converter.GenericHttpMessageConverter<Object>
    • canWrite

      public boolean canWrite(Type type, Class<?> clazz, org.springframework.http.MediaType mediaType)
      Specified by:
      canWrite in interface org.springframework.http.converter.GenericHttpMessageConverter<Object>
    • read

      public Object read(Type type, Class<?> contextClass, org.springframework.http.HttpInputMessage inputMessage) throws IOException, org.springframework.http.converter.HttpMessageNotReadableException
      Specified by:
      read in interface org.springframework.http.converter.GenericHttpMessageConverter<Object>
      Throws:
      IOException
      org.springframework.http.converter.HttpMessageNotReadableException
    • write

      public void write(Object o, Type type, org.springframework.http.MediaType contentType, org.springframework.http.HttpOutputMessage outputMessage) throws IOException, org.springframework.http.converter.HttpMessageNotWritableException
      Specified by:
      write in interface org.springframework.http.converter.GenericHttpMessageConverter<Object>
      Throws:
      IOException
      org.springframework.http.converter.HttpMessageNotWritableException
    • readInternal

      protected Object readInternal(Class<?> clazz, org.springframework.http.HttpInputMessage inputMessage) throws IOException, org.springframework.http.converter.HttpMessageNotReadableException
      Specified by:
      readInternal in class org.springframework.http.converter.AbstractHttpMessageConverter<Object>
      Throws:
      IOException
      org.springframework.http.converter.HttpMessageNotReadableException
    • writeInternal

      protected void writeInternal(Object object, org.springframework.http.HttpOutputMessage outputMessage) throws IOException, org.springframework.http.converter.HttpMessageNotWritableException
      Specified by:
      writeInternal in class org.springframework.http.converter.AbstractHttpMessageConverter<Object>
      Throws:
      IOException
      org.springframework.http.converter.HttpMessageNotWritableException
    • getType

      protected Type getType(Type type, Class<?> contextClass)