您当前的位置: 首页 >  json

qq_34412985

暂无认证

  • 1浏览

    0关注

    1061博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

springboot自定义json解析框架

qq_34412985 发布时间:2019-09-17 13:06:37 ,浏览量:1

我们要使用第三方的json解析框架的话: 1、我们需要在pom.xml中引入相应的依赖; 2、需要在App.java中继承WebMvcConfigurerAdapter重写方法:configureMessageConverters 添加我们自己定义的json解析框架; 2.1 @Bean注入第三方的json解析框架:

@Bean public HttpMessageConverters fastJsonHttpMessageConverters() {     // 1、需要先定义一个 convert 转换消息的对象;     FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();          //2、添加fastJson 的配置信息,比如:是否要格式化返回的json数据;     FastJsonConfig fastJsonConfig = new FastJsonConfig();     fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);          //3、在convert中添加配置信息.     fastConverter.setFastJsonConfig(fastJsonConfig);               HttpMessageConverter converter = fastConverter;     return new HttpMessageConverters(converter); }

关注
打赏
1653291990
查看更多评论
立即登录/注册

微信扫码登录

0.0431s