当前位置:网站首页>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边栏推荐
- Two way data binding in wechat applet
- 深入解析 Apache BookKeeper 系列:第四篇—背压
- Classic case of multithreading
- When unittest automatically tests multiple use cases, the logging module prints repeatedly to solve the problem
- Web APIs comprehensive case -tab column switching - dark horse programmer
- [micro service ~nacos] configuration center of Nacos
- [450. delete nodes in binary search tree]
- Spark - understand partitioner in one article
- What does the &?
- What are database OLAP and OLTP? Same and different? Applicable scenarios
猜你喜欢

电脑设备管理器在哪里可以找到

JMeter cross thread parameter association requires no script

微信小程序中的数据双向绑定

Classic case of multithreading

多线程经典案例

How to upload binary pictures in uniapp

总结的一些内存问题
![[无线通信基础-13]:图解移动通信技术与应用发展-1-概述](/img/1d/62e55f1b5445d7349ec383879f4275.png)
[无线通信基础-13]:图解移动通信技术与应用发展-1-概述

MIT doctoral dissertation optimization theory and machine learning practice

Redis' cache penetration, cache breakdown and cache avalanche
随机推荐
[golang] golang实现截取字符串函数SubStr
理想中的接口自动化项目
在线客服聊天系统源码_美观强大golang内核开发_二进制运行傻瓜式安装_附搭建教程...
How to develop the exchange system? Mature technology case of digital currency exchange system development
[无线通信基础-13]:图解移动通信技术与应用发展-1-概述
软件确认测试的内容和流程有哪些?确认测试报告需要多少钱?
ESP8266 成为客户端和服务器
"Paddle + camera" has become a "prefabricated dish" in the AI world, and it is easier to implement industrial AI quality inspection
Go language learning notes - Gorm usage - database configuration, table addition | web framework gin (VII)
在线客服系统代码_h5客服_对接公众号_支持APP_支持多语言
多線程經典案例
The superficial understanding of the industrial Internet finally brought the development of the industrial Internet into the strange circle of the consumer Internet
In depth analysis of Apache bookkeeper series: Part 4 - back pressure
Tencent has been conducting advanced automated functional testing for 3 years. It is a gift to you who are confused in manual testing
Win11如何优化服务?Win11优化服务的方法
Discuz forum speed up to delete XXX under data/log PHP file
KubeVela 1.4:让应用交付更安全、上手更简单、过程更透明
MFC interface library bcgcontrolbar v33.0 - desktop alarm window, grid control upgrade, etc
What does the software test report contain? How to obtain high quality software test reports?
leetcode:104. Maximum depth of binary tree