Java Code Examples for com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter#setSupportedMediaTypes()

The following examples show how to use com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter#setSupportedMediaTypes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomMVCConfiguration.java    From spring-boot-starter-netty with GNU General Public License v3.0 6 votes vote down vote up
@Bean
FastJsonHttpMessageConverter getFastJsonConv() {
    FastJsonHttpMessageConverter conv = new FastJsonHttpMessageConverter();

    FastJsonConfig oFastJsonConfig = new FastJsonConfig();
    oFastJsonConfig.setSerializerFeatures(
            SerializerFeature.WriteMapNullValue,
            SerializerFeature.WriteDateUseDateFormat
    );
    conv.setFastJsonConfig(oFastJsonConfig);

    List<MediaType> types = new ArrayList<>();
    types.add(MediaType.APPLICATION_JSON_UTF8);
    types.add(MediaType.APPLICATION_JSON);
    conv.setSupportedMediaTypes(types);
    return conv;
}
 
Example 2
Source File: WebMvcConfigurer.java    From mysiteforme with Apache License 2.0 6 votes vote down vote up
/**
 *  fastjson序列化
 *
 * */
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    super.configureMessageConverters(converters);
    List<MediaType> supportedMediaTypes = new ArrayList<>();
    supportedMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
    FastJsonHttpMessageConverter fastJsonHttpMessageConverter = new FastJsonHttpMessageConverter();
    fastJsonHttpMessageConverter.setSupportedMediaTypes(supportedMediaTypes);
    FastJsonConfig fastJsonConfig = new FastJsonConfig();
    fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");    // 自定义时间格式
    fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat,SerializerFeature.DisableCircularReferenceDetect,
            SerializerFeature.WriteNullNumberAsZero,SerializerFeature.WriteNullBooleanAsFalse,SerializerFeature.WriteMapNullValue,
            SerializerFeature.WriteNullStringAsEmpty,SerializerFeature.WriteNullListAsEmpty,SerializerFeature.WriteDateUseDateFormat,
            SerializerFeature.BrowserCompatible,SerializerFeature.WriteNonStringKeyAsString);
    converters.add(fastJsonHttpMessageConverter);
    converters.add(responseBodyConverter());
}
 
Example 3
Source File: BeanConfig.java    From xmfcn-spring-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * 替换springMVC JSON格式化工具为FastJSON,同时支持输出value=null的字段
 *
 * @return http message converters
 */
@Bean
public HttpMessageConverters fastJsonHttpMessageConverters() {
    //1.需要定义一个convert转换消息的对象;
    FastJsonHttpMessageConverter fastJsonHttpMessageConverter = new FastJsonHttpMessageConverter();
    //2:添加fastJson的配置信息;
    FastJsonConfig fastJsonConfig = new FastJsonConfig();
    fastJsonConfig.setSerializerFeatures(SerializerFeature.WriteMapNullValue);
    fastJsonConfig.setSerializeFilters();
    //3处理中文乱码问题
    List<MediaType> fastMediaTypes = new ArrayList<>();
    fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
    //4.在convert中添加配置信息.
    fastJsonHttpMessageConverter.setSupportedMediaTypes(fastMediaTypes);
    fastJsonHttpMessageConverter.setFastJsonConfig(fastJsonConfig);
    return new HttpMessageConverters(fastJsonHttpMessageConverter);

}
 
Example 4
Source File: BeanConfig.java    From xmfcn-spring-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * 替换springMVC JSON格式化工具为FastJSON,同时支持输出value=null的字段
 *
 * @return http message converters
 */
@Bean
public HttpMessageConverters fastJsonHttpMessageConverters() {
    //1.需要定义一个convert转换消息的对象;
    FastJsonHttpMessageConverter fastJsonHttpMessageConverter = new FastJsonHttpMessageConverter();
    //2:添加fastJson的配置信息;
    FastJsonConfig fastJsonConfig = new FastJsonConfig();
    fastJsonConfig.setSerializerFeatures(SerializerFeature.WriteMapNullValue);
    fastJsonConfig.setSerializeFilters();
    //3处理中文乱码问题
    List<MediaType> fastMediaTypes = new ArrayList<>();
    fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
    //4.在convert中添加配置信息.
    fastJsonHttpMessageConverter.setSupportedMediaTypes(fastMediaTypes);
    fastJsonHttpMessageConverter.setFastJsonConfig(fastJsonConfig);
    return new HttpMessageConverters(fastJsonHttpMessageConverter);

}
 
Example 5
Source File: WebMvcConfig.java    From littleca with Apache License 2.0 6 votes vote down vote up
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    //1.需要定义一个convert转换消息的对象;
    FastJsonHttpMessageConverter fastJsonHttpMessageConverter = new FastJsonHttpMessageConverter();
    //2.添加fastJson的配置信息,比如:是否要格式化返回的json数据;
    FastJsonConfig fastJsonConfig = new FastJsonConfig();
    fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
    //3处理中文乱码问题
    List<MediaType> fastMediaTypes = new ArrayList<>();
    fastMediaTypes.add(MediaType.APPLICATION_JSON);
    fastJsonConfig.setCharset(Charset.forName("UTF-8"));
    //4.在convert中添加配置信息.
    fastJsonHttpMessageConverter.setSupportedMediaTypes(fastMediaTypes);
    fastJsonHttpMessageConverter.setFastJsonConfig(fastJsonConfig);
    //5.将convert添加到converters当中.
    converters.add(1,fastJsonHttpMessageConverter);
}
 
Example 6
Source File: WebMvcConfig.java    From littleca with Apache License 2.0 6 votes vote down vote up
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    //1.需要定义一个convert转换消息的对象;
    FastJsonHttpMessageConverter fastJsonHttpMessageConverter = new FastJsonHttpMessageConverter();
    //2.添加fastJson的配置信息,比如:是否要格式化返回的json数据;
    FastJsonConfig fastJsonConfig = new FastJsonConfig();
    fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
    //3处理中文乱码问题
    List<MediaType> fastMediaTypes = new ArrayList<>();
    fastMediaTypes.add(MediaType.APPLICATION_JSON);
    fastJsonConfig.setCharset(Charset.forName("UTF-8"));
    //4.在convert中添加配置信息.
    fastJsonHttpMessageConverter.setSupportedMediaTypes(fastMediaTypes);
    fastJsonHttpMessageConverter.setFastJsonConfig(fastJsonConfig);
    //5.将convert添加到converters当中.
    converters.add(1, fastJsonHttpMessageConverter);
}
 
Example 7
Source File: WebMvcConfig.java    From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International 6 votes vote down vote up
/**
 * 自定义消息转换器:使用 Fastjson 替换 Spring Boot 默认使用的 Jackson
 *
 * @param converters 消息转换器
 */
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    // 清除默认 Json 转换器
    converters.removeIf(converter -> converter instanceof MappingJackson2HttpMessageConverter);

    // 配置 FastJson
    FastJsonConfig config = new FastJsonConfig();
    config.setSerializerFeatures(SerializerFeature.QuoteFieldNames, SerializerFeature.WriteEnumUsingToString,
        SerializerFeature.WriteMapNullValue, SerializerFeature.WriteDateUseDateFormat);

    // 添加 FastJsonHttpMessageConverter
    FastJsonHttpMessageConverter fastJsonHttpMessageConverter = new FastJsonHttpMessageConverter();
    fastJsonHttpMessageConverter.setFastJsonConfig(config);
    List<MediaType> fastMediaTypes = new ArrayList<>();
    fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
    fastJsonHttpMessageConverter.setSupportedMediaTypes(fastMediaTypes);
    converters.add(fastJsonHttpMessageConverter);

    // 添加 StringHttpMessageConverter,解决中文乱码问题
    StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(StandardCharsets.UTF_8);
    converters.add(stringHttpMessageConverter);


}
 
Example 8
Source File: RedisConfig.java    From sophia_scaffolding with Apache License 2.0 6 votes vote down vote up
/**
 *  使用@Bean注入fastJsonHttpMessageConvert,fastJson序列化
 */
@Bean
public HttpMessageConverters fastJsonHttpMessageConverters(){
    // 1、需要先定义一个 convert 转换消息的对象;
    FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
    //2、添加fastJson 的配置信息,比如:是否要格式化返回的json数据;
    FastJsonConfig fastJsonConfig = new FastJsonConfig();
    fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);

    //2-1 处理中文乱码问题
    List<MediaType> fastMediaTypes = new ArrayList<>();
    fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
    fastConverter.setSupportedMediaTypes(fastMediaTypes);

    //3、在convert中添加配置信息.
    fastConverter.setFastJsonConfig(fastJsonConfig);
    HttpMessageConverter<?> converter = fastConverter;
    return new HttpMessageConverters(converter);
}
 
Example 9
Source File: RedisConfig.java    From sophia_scaffolding with Apache License 2.0 6 votes vote down vote up
/**
 *  使用@Bean注入fastJsonHttpMessageConvert,fastJson序列化
 */
@Bean
public HttpMessageConverters fastJsonHttpMessageConverters(){
    // 1、需要先定义一个 convert 转换消息的对象;
    FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
    //2、添加fastJson 的配置信息,比如:是否要格式化返回的json数据;
    FastJsonConfig fastJsonConfig = new FastJsonConfig();
    fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);

    //2-1 处理中文乱码问题
    List<MediaType> fastMediaTypes = new ArrayList<>();
    fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
    fastConverter.setSupportedMediaTypes(fastMediaTypes);

    //3、在convert中添加配置信息.
    fastConverter.setFastJsonConfig(fastJsonConfig);
    HttpMessageConverter<?> converter = fastConverter;
    return new HttpMessageConverters(converter);
}
 
Example 10
Source File: RedisConfig.java    From sophia_scaffolding with Apache License 2.0 6 votes vote down vote up
/**
 *  使用@Bean注入fastJsonHttpMessageConvert,fastJson序列化
 */
@Bean
public HttpMessageConverters fastJsonHttpMessageConverters(){
    // 1、需要先定义一个 convert 转换消息的对象;
    FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
    //2、添加fastJson 的配置信息,比如:是否要格式化返回的json数据;
    FastJsonConfig fastJsonConfig = new FastJsonConfig();
    fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);

    //2-1 处理中文乱码问题
    List<MediaType> fastMediaTypes = new ArrayList<>();
    fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
    fastConverter.setSupportedMediaTypes(fastMediaTypes);

    //3、在convert中添加配置信息.
    fastConverter.setFastJsonConfig(fastJsonConfig);
    HttpMessageConverter<?> converter = fastConverter;
    return new HttpMessageConverters(converter);
}
 
Example 11
Source File: FastJsonConfiguration.java    From momo-cloud-permission with Apache License 2.0 6 votes vote down vote up
@Bean
public HttpMessageConverters fastJsonConfigure(){
    FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
    FastJsonConfig fastJsonConfig = new FastJsonConfig();
    fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
    //日期格式化
    fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
    //修改配置返回内容的过滤
    fastJsonConfig.setSerializerFeatures(
            SerializerFeature. WriteMapNullValue,//是否输出值为null的字段,默认为false
            SerializerFeature.WriteDateUseDateFormat,//格式化标签
    		SerializerFeature.WriteNullListAsEmpty , //List字段如果为null,输出为[],而非null
            SerializerFeature.DisableCircularReferenceDetect,//消除对同一对象循环引用的问题,默认为false(如果不配置有可能会进入死循环)
            SerializerFeature.WriteMapNullValue,//是否输出值为null的字段,默认为false。
            SerializerFeature.WriteNullStringAsEmpty,//字符类型字段如果为null,输出为"",而非null
            SerializerFeature.WriteNullBooleanAsFalse//Boolean字段如果为null,输出为false,而非null
    );
    converter.setFastJsonConfig(fastJsonConfig);
    //处理中文乱码问题
    List<MediaType> fastMediaTypes = new ArrayList<>();
    fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
    converter.setSupportedMediaTypes(fastMediaTypes);
    converter.setFastJsonConfig(fastJsonConfig);
    //将fastjson添加到视图消息转换器列表内
    return new HttpMessageConverters(converter);
}
 
Example 12
Source File: FastJsonConfiguration.java    From momo-cloud-permission with Apache License 2.0 6 votes vote down vote up
@Bean
    public HttpMessageConverters fastJsonConfigure(){
        FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
        FastJsonConfig fastJsonConfig = new FastJsonConfig();
        fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
        //日期格式化
        fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
        //修改配置返回内容的过滤
        fastJsonConfig.setSerializerFeatures(
//                SerializerFeature. WriteMapNullValue,//是否输出值为null的字段,默认为false
                SerializerFeature.WriteDateUseDateFormat//格式化标签
//        		SerializerFeature.WriteNullListAsEmpty  ,//List字段如果为null,输出为[],而非null
//                SerializerFeature.DisableCircularReferenceDetect,//消除对同一对象循环引用的问题,默认为false(如果不配置有可能会进入死循环)
//                SerializerFeature.WriteMapNullValue,//是否输出值为null的字段,默认为false。
//                SerializerFeature.WriteNullStringAsEmpty//字符类型字段如果为null,输出为"",而非null
//                SerializerFeature.WriteNullBooleanAsFalse//Boolean字段如果为null,输出为false,而非null
        );
        converter.setFastJsonConfig(fastJsonConfig);
        //处理中文乱码问题
        List<MediaType> fastMediaTypes = new ArrayList<>();
        fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
        converter.setSupportedMediaTypes(fastMediaTypes);
        converter.setFastJsonConfig(fastJsonConfig);
        //将fastjson添加到视图消息转换器列表内
        return new HttpMessageConverters(converter);
    }
 
Example 13
Source File: FastjsonConfig.java    From spring-boot-demo-all with Apache License 2.0 6 votes vote down vote up
@Bean
public FastJsonHttpMessageConverter fastJsonHttpMessageConverter() {
    FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
    FastJsonConfig fastJsonConfig = new FastJsonConfig();
    fastJsonConfig.setSerializerFeatures(
            SerializerFeature.PrettyFormat,
            SerializerFeature.WriteClassName,
            SerializerFeature.WriteMapNullValue
    );
    List<MediaType> fastMediaTypes = new ArrayList<MediaType>();
    fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);

    fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
    ValueFilter valueFilter = new ValueFilter() {
        public Object process(Object o, String s, Object o1) {
            if (null == o1) {
                o1 = "";
            }
            return o1;
        }
    };
    fastJsonConfig.setSerializeFilters(valueFilter);
    converter.setSupportedMediaTypes(fastMediaTypes);
    converter.setFastJsonConfig(fastJsonConfig);
    return converter;
}
 
Example 14
Source File: SmartRestTemplateConfig.java    From smart-admin with MIT License 6 votes vote down vote up
/**
 * fastJsonRestTemplate
 *
 * @return
 */
@Bean(name = "fastJsonRestTemplate")
public RestTemplate fastJsonRestTemplate() {
    RestTemplate restTemplate = new RestTemplate(httpRequestFactory());

    HttpMessageConverter<?> converter = new StringHttpMessageConverter(Charset.forName("UTF-8"));

    FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
    List<MediaType> fastMediaTypes = new ArrayList<>();
    fastMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED);
    fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
    fastConverter.setSupportedMediaTypes(fastMediaTypes);
    List<HttpMessageConverter<?>> converters = restTemplate.getMessageConverters();
    converters.add(1,converter);
    converters.add(fastConverter);
    return restTemplate;
}
 
Example 15
Source File: Application.java    From AthenaServing with Apache License 2.0 5 votes vote down vote up
/**
 * fastjson 转换器
 *
 * @param converters
 */
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
	super.configureMessageConverters(converters);
	FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
	FastJsonConfig fastJsonConfig = new FastJsonConfig();
	fastJsonConfig.setSerializerFeatures(SerializerFeature.WriteMapNullValue);
	List<MediaType> fastMediaTypes = new ArrayList<>();
	fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
	fastConverter.setSupportedMediaTypes(fastMediaTypes);
	fastConverter.setFastJsonConfig(fastJsonConfig);
	converters.add(fastConverter);
}
 
Example 16
Source File: WebMvcConfig.java    From spring-boot-vue-admin with Apache License 2.0 5 votes vote down vote up
/** 使用阿里 FastJson 作为 JSON MessageConverter */
@Override
public void configureMessageConverters(final List<HttpMessageConverter<?>> converters) {
  final FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
  final FastJsonConfig config = new FastJsonConfig();
  converter.setSupportedMediaTypes(
      new ArrayList<MediaType>() {
        private static final long serialVersionUID = 1924772982095119650L;

        {
          this.add(MediaType.APPLICATION_JSON_UTF8);
          this.add(MediaType.APPLICATION_OCTET_STREAM);
          this.add(MediaType.IMAGE_GIF);
          this.add(MediaType.IMAGE_JPEG);
          this.add(MediaType.IMAGE_PNG);
        }
      });
  config.setSerializerFeatures(
      // 保留空的字段
      // SerializerFeature.WriteMapNullValue,
      // Number null -> 0
      SerializerFeature.WriteNullNumberAsZero,
      // 美化输出
      SerializerFeature.PrettyFormat);
  converter.setFastJsonConfig(config);
  converter.setDefaultCharset(StandardCharsets.UTF_8);
  converters.add(converter);
}
 
Example 17
Source File: ApplicationConfiguration.java    From spring-cloud-shop with MIT License 5 votes vote down vote up
@Bean
public HttpMessageConverters fastJsonConfigure() {
    FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
    FastJsonConfig fastJsonConfig = new FastJsonConfig();
    fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
    converter.setFastJsonConfig(fastJsonConfig);

    List<MediaType> supportedMediaTypes = new ArrayList<>();

    supportedMediaTypes.add(MediaType.APPLICATION_JSON);
    supportedMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
    supportedMediaTypes.add(MediaType.APPLICATION_ATOM_XML);
    supportedMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED);
    supportedMediaTypes.add(MediaType.APPLICATION_OCTET_STREAM);
    supportedMediaTypes.add(MediaType.APPLICATION_PDF);
    supportedMediaTypes.add(MediaType.APPLICATION_RSS_XML);
    supportedMediaTypes.add(MediaType.APPLICATION_XHTML_XML);
    supportedMediaTypes.add(MediaType.APPLICATION_XML);
    supportedMediaTypes.add(MediaType.IMAGE_GIF);
    supportedMediaTypes.add(MediaType.IMAGE_JPEG);
    supportedMediaTypes.add(MediaType.IMAGE_PNG);
    supportedMediaTypes.add(MediaType.TEXT_EVENT_STREAM);
    supportedMediaTypes.add(MediaType.TEXT_HTML);
    supportedMediaTypes.add(MediaType.TEXT_MARKDOWN);
    supportedMediaTypes.add(MediaType.TEXT_PLAIN);
    supportedMediaTypes.add(MediaType.TEXT_XML);
    converter.setSupportedMediaTypes(supportedMediaTypes);
    return new HttpMessageConverters(converter);
}
 
Example 18
Source File: WebConfig.java    From SpringBoot-Home with Apache License 2.0 5 votes vote down vote up
/**
 * 启用 FastJson: https://github.com/alibaba/fastjson/wiki/%E5%9C%A8-Spring-%E4%B8%AD%E9%9B%86%E6%88%90-Fastjson
 * @param converters
 */
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
    converter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON_UTF8));
    //自定义配置...
    FastJsonConfig config = new FastJsonConfig();
    //- https://github.com/alibaba/fastjson/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98
    //- 不用 WriteDateUseDateFormat ,日期由客户端自行格式化
    //- 不用 WriteMapNullValue ,默认不输出属性值为null的字段
    //- BrowserCompatible ,会把中文编码为Unicode转义字符,需要的时候可以加上
    config.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect);
    converter.setFastJsonConfig(config);
    converters.add(0, converter);
}
 
Example 19
Source File: WebConfig.java    From SpringBoot-Home with Apache License 2.0 5 votes vote down vote up
/**
 * 启用 FastJson: https://github.com/alibaba/fastjson/wiki/%E5%9C%A8-Spring-%E4%B8%AD%E9%9B%86%E6%88%90-Fastjson
 * @param converters
 */
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
    converter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON_UTF8));
    //自定义配置...
    FastJsonConfig config = new FastJsonConfig();
    //- https://github.com/alibaba/fastjson/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98
    //- 不用 WriteDateUseDateFormat ,日期由客户端自行格式化
    //- 不用 WriteMapNullValue ,默认不输出属性值为null的字段
    //- BrowserCompatible ,会把中文编码为Unicode转义字符,需要的时候可以加上
    config.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect);
    converter.setFastJsonConfig(config);
    converters.add(0, converter);
}
 
Example 20
Source File: DefaultFastjsonConfig.java    From MeetingFilm with Apache License 2.0 5 votes vote down vote up
@Bean
public FastJsonHttpMessageConverter fastJsonHttpMessageConverter() {
    FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
    converter.setFastJsonConfig(fastjsonConfig());
    converter.setSupportedMediaTypes(getSupportedMediaType());
    return converter;
}