This article mainly introduces the generation and parsing of json data (serialization and deserialization data) by fastjson in java. It has certain reference value. Interested friends can refer to it.
This article explains 2 points:
1. Fastjson generates and parses json data
(Example: 4 common types :JavaBean,List,List,List
2. Test the usage of fastjson through an android program.
Introduction to fastjson:
Fastjson is a high-performance and complete JSON library written in Java language. fastjson uses an original algorithm to increase the speed of parse to the extreme, surpassing all json libraries, including jackson, which was once known as the fastest. And it also surpasses Google's binary protocol protocol buf. Fastjson fully supports the standard of //m.sbmmt.com/ and is also one of the reference implementations included on the official website. Various JDK types are supported. Including basic types, JavaBean, Collection, Map, Enum, generics, etc. Supports JDK 5, JDK 6, Android, Alibaba Cloud mobile phones and other environments.
##1. fastjson generates json string (JavaBean,List,List,List
String jsonStrng = JSON.toJSONString(object);
Copy after login
2. fastjson parses json string into four types
1. JavaBean
Person person = JSON.parseObject(jsonString, Person.class);
Copy after login
2. List
List<Person> listPerson =JSON.parseArray(jsonString, Person.class);
Copy after login
3. ListList<String> listString = JSON.parseArray(jsonString, String.class);
Copy after login
4. List