Class 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 org.springframework.http.MediaType APPLICATION_JAVASCRIPT  
      • Fields inherited from class org.springframework.http.converter.AbstractHttpMessageConverter

        logger
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      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)  
      FastJsonConfig getFastJsonConfig()  
      protected Type getType​(Type type, Class<?> contextClass)  
      Object read​(Type type, Class<?> contextClass, org.springframework.http.HttpInputMessage inputMessage)  
      protected Object readInternal​(Class<?> clazz, org.springframework.http.HttpInputMessage inputMessage)  
      void setFastJsonConfig​(FastJsonConfig fastJsonConfig)  
      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 interface org.springframework.http.converter.HttpMessageConverter

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

      • APPLICATION_JAVASCRIPT

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

      • FastJsonHttpMessageConverter

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

      • 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)