}
====================== Dividing Line
Alibaba FastJson is a Json processing toolkit , including "serialization" and "deserialization" of the two parts , it has the following characteristics :
The fastest, tests show that fastjson has a very fast performance, beyond any other Java Jsonparser. including the self-proclaimed fastest JackJson;
powerful , full support for Java Bean, collection , Map, date , Enum, support paradigm , support for introspection ; no dependencies , can run directly on Java SE5.0 or later ; support for Android ; open source (Apache 2.0)
Second, FastJson parsing JSON steps
A. Server-side conversion of data into json strings
First, the server-side project to import Alibaba's fastjson jar package to the builtPath path (these can be downloaded from the fastjson website: /wiki/display/FastJSON/Home-zh)
The data is then converted to a json string and the core function is:
public static String createJsonString(Object value)
{
String alibabaJson = (value);
return alibabaJson;
}
B. The client will convert the json string to the corresponding javaBean
First, the client should also import the two fastjson jar packages
1, the client to get the json string
public class HttpUtil
{
public static String getJsonContent(String urlStr)
{
try
====================== Dividing Line
Alibaba FastJson is a Json processing toolkit , including "serialization" and "deserialization" of the two parts , it has the following characteristics :
The fastest, tests show that fastjson has a very fast performance, beyond any other Java Jsonparser. including the self-proclaimed fastest JackJson;
powerful , full support for Java Bean, collection , Map, date , Enum, support paradigm , support for introspection ; no dependencies , can run directly on Java SE5.0 or later ; support for Android ; open source (Apache 2.0)
FastjsonAPI entry class is that common serialization operations can be done directly in static methods on the JSON class.
public
static
final
Objectparse(Stringtext);
// parse JSON text to JSONObject or JSONArray.
publicstatic
final
JSONObjectparseObject(Stringtext);
//parse JSON text to JSONObject
publicstatic
final
T parseObject(String text, Classclazz);
//parse JSON text to JavaBean
publicstatic
final
JSONArrayparseArray(Stringtext);
//parse JSON text into JSONArray
publicstatic
final
List parseArray(String text, Classclazz);
// parse JSON text into a collection of JavaBeans.
publicstatic
final
StringtoJSONString(Objectobject);
// Serialize JavaBean to JSON text
publicstatic
final
StringtoJSONString(Objectobject,
boolean
prettyFormat);
// Serialize JavaBean to formatted JSON text
publicstatic
final
ObjecttoJSON(Object javaObject); Convert a JavaBean to a JSONObject or JSONArray.
public
public
public
public
public
public
public
Second, FastJson parsing JSON steps
public static String createJsonString(Object value)
B. The client will convert the json string to the corresponding javaBean
1, the client to get the json string
public class HttpUtil
{