当前位置:网站首页>Fastjson V2 simple user manual
Fastjson V2 simple user manual
2022-06-30 22:41:00 【InfoQ】
Preface
JSONJSONJSECMA262ECMA404rfc4627JSONJSONJSONJSONfalsenulltrueobjectarraynumberstring{}key:value[],JSON{
"baseInfo": {
"name": "cunyu1943",
"wepublic": " Village Yuyao ",
"wechat": "cunyu1024",
"platform": ["juejin", "CSDN", "Github", "zhihu"]
}
}
JSONFastjson: Developed by domestic Alibaba companyJSONlibrary , Superior performance and speed .
Jackson:SpringdefaultJSONlibrary , The community is very active , Update iteration fast .
Gson: From GoogleJSONlibrary , At present, it is the most versatileJSONThe library .
FastjsonFastjsonJSONFastjsonUsing skills
MavenFastjsonFastjson v2MavenMavenpom.xmlFastjson V2<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.6</version>
</dependency>
Hero@Data
@NoArgsConstructor
@AllArgsConstructor
public class Hero {
private String sex;
private String name;
private String profession;
}
Java Object serialization to JSON
HerotoJSONString()JSONpublic class MainApplication {
public static void main(String[] args) {
// Java Object turn JSON
Hero hero = new Hero(" Woman ", " concubine ", " striker ");
String heroJson = JSON.toJSONString(hero);
System.out.println(heroJson);
}
}

JSON It can be interpreted as Java object
JSONparseObject()public class MainApplication {
public static void main(String[] args) {
// JSON String rotation Java object
String shooter = "{"name":" Galois ","profession":" striker ","sex":" Woman "}";
Hero hero = JSON.parseObject(shooter, Hero.class);
System.out.println(hero.toString());
}
}

JSON It can be interpreted as JSONObject
JSONJSONObjectJSONpublic class MainApplication {
public static void main(String[] args) {
// JSON It can be interpreted as JSONObject
String shooter = "{"name":" Huang Zhong ","profession":" striker ","sex":" male "}";
JSONObject heroJson = JSON.parseObject(shooter);
System.out.println(heroJson.toJSONString());
}
}

JSON It can be interpreted as JSONArray
JSONJSONArrayparseArray()public class MainApplication {
public static void main(String[] args) {
// JSON It can be interpreted as JSONArray
String platform = "[{"name":"CSDN","id":" Village Yuyao "},{"name":"Juejin","id":" Village Yuyao "}]";
JSONArray platformArray = JSON.parseArray(platform);
System.out.println(platformArray.toJSONString());
}
}

summary
JSONJSONFastjson V2Fastjson V2边栏推荐
- 微信小程序中的数据双向绑定
- KVM IO性能测试数据
- 深入解析 Apache BookKeeper 系列:第四篇—背压
- 去中心化交易所系统开发技术原理丨数字货币去中心化交易所系统开发(说明案例)
- 有孚网络混合云,加速企业数字化转型升级
- How cloud computing can protect online education in the post epidemic Era
- Online customer service chat system source code_ Beautiful and powerful golang kernel development_ Binary operation fool installation_ Attached construction tutorial
- 电脑版微信文件存储在哪个文件夹可以找到
- Classic case of multithreading
- ESP8266 成为客户端和服务器
猜你喜欢
![[无线通信基础-13]:图解移动通信技术与应用发展-1-概述](/img/1d/62e55f1b5445d7349ec383879f4275.png)
[无线通信基础-13]:图解移动通信技术与应用发展-1-概述
![Flip the linked list ii[three ways to flip the linked list +dummyhead/ head insertion / tail insertion]](/img/a8/6472e2051a295f5e42a88d64199517.png)
Flip the linked list ii[three ways to flip the linked list +dummyhead/ head insertion / tail insertion]

项目管理到底管的是什么?

Nansen复盘加密巨头自救:如何阻止百亿多米诺倾塌

B_ QuRT_ User_ Guide(33)

B_ QuRT_ User_ Guide(31)

远程办公期间,项目小组微信群打卡 | 社区征文

How to realize the center progress bar in wechat applet

"More Ford, more China" saw through the clouds, and the orders of Changan Ford's flagship products exceeded 10000

公有云市场迈入深水区,冷静的亚马逊云还坐得住吗?
随机推荐
Nansen double disk encryption giant self rescue: how to prevent the collapse of billions of dominoes
leetcode:104. 二叉树的最大深度
How to use filters in jfinal to monitor Druid for SQL execution?
How to develop the exchange system? Mature technology case of digital currency exchange system development
How to upload binary pictures in uniapp
Youfu network hybrid cloud accelerates enterprise digital transformation and upgrading
How to ensure the security of our core drawings by drawing encryption
Two dots on the top of the latex letter
"More Ford, more China" saw through the clouds, and the orders of Changan Ford's flagship products exceeded 10000
How to change the win11 computer name? Win11 method of changing computer name
B_ QuRT_ User_ Guide(35)
How cloud computing can protect online education in the post epidemic Era
公有云市场迈入深水区,冷静的亚马逊云还坐得住吗?
Meet the streamnational | yangzike: what made me give up Dachang offer
Apache server OpenSSL upgrade
请指教同花顺软件究竟是什么?另外想问,现在在线开户安全么?
Tencent has been conducting advanced automated functional testing for 3 years. It is a gift to you who are confused in manual testing
What are database OLAP and OLTP? Same and different? Applicable scenarios
基于kubernetes平台微服务的部署
Redis' transaction and locking mechanism