FastJson tutorial manual

Read(13981) update time(2022-04-19)

Fastjson is a high-performance and complete JSON library written in Java language. It uses an "assumed ordered fast matching" algorithm to improve the performance of JSON Parse to the extreme. It is currently the fastest JSON library in the Java language. The Fastjson interface is simple and easy to use, and has been widely used in various application scenarios such as cache serialization, protocol interaction, Web output, and Android clients.


fastjson is Alibaba's open source JSON parsing library. It can parse JSON format strings, supports serialization of Java Beans into JSON strings, and can also deserialize from JSON strings to JavaBeans. It has been widely used in various scenarios, including cache storage, RPC communication, MQ communication, network protocol communication, Android client, Ajax server handler, etc.

Tips: Before continuing to learn Fastjson, you need to know something about Java and JSON.

fastjson main features:

  • Fast FAST (faster than any other Java-based parser and generator, including jackson)

  • Powerful (supports ordinary JDK classes including any Java Bean Class, Collection, Map, Date or enum)

  • Zero dependencies (no dependencies on any other class libraries except JDK )

Sample code:

import com.alibaba.fastjson.JSON;
 
Group group = new Group();
group.setId(0L);
group.setName("admin");
 
User guestUser = new User();
guestUser.setId(2L);
guestUser.setName("guest");
 
User rootUser = new User();
rootUser.setId(3L);
rootUser.setName("root");
 
group.getUsers().add(guestUser);
group.getUsers().add(rootUser); 
String jsonString = JSON.toJSONString(group); 
System.out.println(jsonString);

Tips: Our fastjson tutorial will help you learn how to use fastjson step by step, if you have If you have any questions, please go to the PHP Chinese website fastjson community to ask your questions, and enthusiastic netizens will answer them for you.

Download

android developers please seehere

Latest JAR

or through Maven:

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>VERSION_CODE</version>
</dependency>

or through Gradle:

compile 'com.alibaba:fastjson:VERSION_CODE'

use the real release version number of here or here or here, Replace VERSION_CODE, for example 1.2.21

Content covered by this fastjson tutorial manual

This fastjson tutorial manual covers all basic and advanced knowledge of fastjson, including Fastjson Android version, Fastjson custom serialization, and Fastjson processing Detailed introduction to oversized JSON text, Fastjson circular references, and Fastjson common problems and examples.

Tips: Each chapter of this tutorial contains many code examples that will help you better understand and use fastjson.