JSON JAVA Summary

Source: Internet
Author: User

The following is the MAVEN coordinates of the JSON third-party jar package I used:

<!--a jar that can be referenced -<Dependency><groupId>Net.sf.json-lib</groupId><Artifactid>Json-lib</Artifactid><version>2.4</version><classifier>Jdk15</classifier></Dependency><!--Source Code -<Dependency><groupId>Net.sf.json-lib</groupId><Artifactid>Json-lib</Artifactid><version>2.4</version><classifier>Jdk15-sources</classifier></Dependency>
View Code

Description of the methods commonly used in Jsonobject:

1  PackageCn.json;2 3 4 ImportNet.sf.json.JSONObject;5 6  Public classJsondemo {7     PrivateJsonobject json=NewJsonobject ();8     9     Ten      Public Static voidMain (string[] args) { One         NewJsondemo (). put (); A         /**< results > - * Insert to null object - * {"accumulate": null} the * insert for null string - * {"accumulate": [Null,null], "element": null, "put": null} - * Insertion of strings - * {"accumulate": [Null,null, ""], "element": "", "Put": ""} +          * */  -     }     +      A     /** at * JSON Insert method comparison - * 1.accumulate method, can be inserted on a null object, - * When inserting multiple value values of the same key, value is arranged in an array of insert orders - * 2.element and put method insert null object - * This key-value disappears, inserting multiple identical key-value, and eventually only the last -      */ in      Public voidput () { -System.out.println ("Insert to null object"); toString value=NULL; +Json.element ("element", value); -Json.accumulate ("Accumulate", value); theJson.put ("Put", value); * System.out.println (JSON); $System.out.println ("Insert to null string");Panax NotoginsengValue= "NULL"; -Json.element ("element", value); theJson.accumulate ("Accumulate", value); +Json.put ("Put", value); A System.out.println (JSON); theSystem.out.println ("Insert for" + "+" string "); +Value= ""; -Json.element ("element", value); $Json.accumulate ("Accumulate", value); $Json.put ("Put", value); - System.out.println (JSON); -          the     }; -     Wuyi}
View Code

JSON JAVA Summary

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.