Fastjson Common methods

Source: Internet
Author: User
Tags object object

First, what exactly isJSON ?

JSON is a string of strings except that the elements are labeled with a particular symbol.

{} Double brackets represent objects

[] brackets represent the array

"" In double quotes is a property or value

: A colon indicates that the latter is a value (the value can be a string, a number, or another array or object)

So {"name": "Michael"} can be understood as an object containing the name Michael

And [{"Name": "Michael"},{"name": "Jerry"}] represents an array containing two objects

Of course, you can also use {"Name": ["Michael", "Jerry"]} to simplify the above, which is an object with a name array

Note: {"ABC"} is not in JSON format, the JSON format is in the form of a key-value pair.

to the Fastjson: the usual methods are as follows:

Public static final Object parse (String text); The
parse the JSON text as Jsonobject or Jsonarray.

public static final Jsonobject parseobject (String text);
Parse the JSON text into Jsonobject.

public static final <T> T parseobject (String text, class<t> clazz);  
Parse the JSON text as JavaBean.

public static final Jsonarray Parsearray (String text);
Parse the JSON text into Jsonarray.

public static final <T> list<t> Parsearray (String text, class<t> clazz);
/parse the JSON text into a JavaBean collection.

public static final String tojsonstring (Object object);
Serializes the JavaBean into JSON text.

public static final String tojsonstring (Object object, Boolean prettyformat);
Serializes the JavaBean into formatted JSON text.

public static final object ToJSON (object javaobject);
Convert JavaBean to Jsonobject or Jsonarray.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.