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