当前位置:网站首页>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边栏推荐
- During telecommuting, the project team punched in the wechat group | solicited papers from the community
- Neo4j load CSV configuration and use
- Some memory problems summarized
- B_ QuRT_ User_ Guide(31)
- 请指教同花顺软件究竟是什么?另外想问,现在在线开户安全么?
- latex左侧大括号 latex中大括号多行公式
- What are the contents and processes of software validation testing? How much does it cost to confirm the test report?
- Nansen复盘加密巨头自救:如何阻止百亿多米诺倾塌
- pytorch 的Conv2d的详细解释
- Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could
猜你喜欢

RP prototype resource sharing - shopping app

公有云市场迈入深水区,冷静的亚马逊云还坐得住吗?

Two dots on the top of the latex letter

Redis - 01 缓存:如何利用读缓存提高系统性能?

latex中 & 号什么含义?

多线程经典案例

RIDE:获取图片base64

深入解析 Apache BookKeeper 系列:第四篇—背压
![[Android, kotlin, tflite] mobile device integration deep learning light model tflite (object detection)](/img/7e/3e6ebfb90a82249d934296a041ba21.png)
[Android, kotlin, tflite] mobile device integration deep learning light model tflite (object detection)

Introduction to machine learning compilation course learning notes lesson 2 tensor program abstraction
随机推荐
电脑版微信文件存储在哪个文件夹可以找到
Esp8266 becomes client and server
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could
Cas classique multithreadé
如何使用 DataAnt 监控 Apache APISIX
Win11电脑名如何更改?Win11更改电脑名的方法
How to design test cases
Youfu network hybrid cloud accelerates enterprise digital transformation and upgrading
Ten of the most heart piercing tests / programmer jokes, read the vast crowd, how to find?
Win11如何优化服务?Win11优化服务的方法
基于kubernetes平台微服务的部署
机器学习编译入门课程学习笔记第二讲 张量程序抽象
B_ QuRT_ User_ Guide(35)
唯一性索引与逻辑删除冲突问题解决思路
智慧路灯| 云计算点亮智慧城市的“星星之火”
win11更新后任务栏空白怎么办? win11更新后任务栏空白卡死的解决方法
Discuz forum speed up to delete XXX under data/log PHP file
Classic case of multithreading
【Android,Kotlin,TFLite】移动设备集成深度学习轻模型TFlite(物体检测篇)
Redis - 01 缓存:如何利用读缓存提高系统性能?