国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務(wù)器之家 - 編程語言 - Java教程 - springboot實現(xiàn)FastJson解析json數(shù)據(jù)的方法

springboot實現(xiàn)FastJson解析json數(shù)據(jù)的方法

2020-09-21 15:58ZhangJQKb Java教程

本篇文章主要介紹了springboot實現(xiàn)FastJson解析json數(shù)據(jù)的方法,非常具有實用價值,需要的朋友可以參考下

最近在研究springboot實現(xiàn)FastJson解析json數(shù)據(jù)的方法,那么今天也算個學(xué)習(xí)筆記吧!

添加jar包:

?
1
2
3
4
5
<dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>fastjson</artifactId>
      <version>1.2.15</version>
  </dependency>

兩種方式啟動加載類:

第一種繼承WebMvcConfigurerAdapter,重寫configureMessageConverters方法:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
 
@SpringBootApplication
public class App extends WebMvcConfigurerAdapter{
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
 
@Override
public void configureMessageConverters(
List<HttpMessageConverter<?>> converters) {
// TODO Auto-generated method stub
super.configureMessageConverters(converters);
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
  
    FastJsonConfig fastJsonConfig = new FastJsonConfig();
    fastJsonConfig.setSerializerFeatures(
        SerializerFeature.PrettyFormat
    );
    fastConverter.setFastJsonConfig(fastJsonConfig);
    
    converters.add(fastConverter);
 

第二種方式bean注入HttpMessageConverters:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.HttpMessageConverter;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
 
@SpringBootApplication
public class AppTwo{
 
public static void main(String[] args) {
SpringApplication.run(AppTwo.class, args);
}
 
@Bean
public HttpMessageConverters fastJsonHttpMessageConverters() {
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
FastJsonConfig fastJsonConfig = new FastJsonConfig();
fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
fastConverter.setFastJsonConfig(fastJsonConfig);
HttpMessageConverter<?> converter = fastConverter;
return new HttpMessageConverters(converter);
}
 
}

最后屬性前加@JSONField:

?
1
2
@JSONField(serialize=false)
private Long id;

返回前端就會沒有id這個屬性值

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。

原文鏈接:http://blog.csdn.net/zhangjq520/article/details/53738736

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 国产精品一区欧美 | 婷色综合 | 色嫩紧中文字幕在线 | 超级碰在线观看 | 日韩欧美在线看 | 亚洲欧美日韩在线 | 最新av在线| 久久久一二三 | 国产av毛片 | 欧美精品v国产精品v日韩精品 | 95香蕉视频 | 中文字幕精品一区 | 狠狠操狠狠干 | 中文字幕一区二区三区精彩视频 | 国产精品国色综合久久 | 亚洲视频一区 | 97久久精品| 国产免费成人 | 成人爽a毛片一区二区免费 成年人毛片视频 | 亚洲视频在线观看 | 欧美一区二区三区精品免费 | 在线一级视频 | а天堂中文最新一区二区三区 | 午夜视频在线免费观看 | 精彩视频一区二区三区 | 激情综合在线观看 | 成人欧美一区二区三区在线播放 | 亚洲专区中文字幕 | 日本高清视频在线播放 | 榴莲视频成人在线观看 | 精品久久久久久久人人人人传媒 | 日韩精品一区二区在线观看 | 日韩av免费在线观看 | 欧美综合视频 | www.亚洲成人 | 黄片毛片免费观看 | 黄色一级免费大片 | 亚洲精品自拍 | 久热精品在线视频 | 免费一级黄色录像 | 欧美伊人 |