Official website: http://json-lib.sourceforge.net/
The jar package that needs to be prepared
1. Json-lib-2.4-jdk15.jar Current latest version, http://sourceforge.net/projects/json-lib/files/
2. HttpClient is used to provide efficient, up-to-date, feature-rich client programming toolkits that support the HTTP protocol. http://hc.apache.org/downloads.cgi
3. Commons Lang This set of APIs provides some basic, general-purpose operations and processing, such as the automatic generation of ToString () results. http://commons.apache.org/lang/download_lang.cgi
4. Commons Logging Apache Universal logging Tool http://commons.apache.org/logging/download_logging.cgi
5. Commons Collections provides a fairly good complement to the Java Standard Collections API Http://commons.apache.org/collections/download_ collections.cgi
6. Commons Beanutils uses the reflection mechanism to process the properties of the JavaBean http://commons.apache.org/beanutils/download_beanutils.cgi
7. Ezmorph is a simple Java class library used to convert one object to another object http://sourceforge.net/projects/ezmorph/files/
public class Accesstoken {
Private String Accesstoken;
private int expiresin;
Public String Getaccess_token () {
return this.accesstoken;
}
public void Setaccess_token (String s) {
This.accesstoken = s;
}
public int getexpires_in () {
return this.expiresin;
}
}
Jsonstring= "Object
String jsonstring = "{\" access_token\ ": \" War3a-1vxsrqbrwuhp0d4vbq5s0rtrgrfucxuuwyv7262jq6higpcwsz5ttwmcifjwjllzehlycuz8huo11qqg\ ", \" expires_in\ ": 7200}"
. replace (' "', ' \ ');
Jsonobject JB = jsonobject.fromobject (jsonstring);
Accesstoken AC = (accesstoken) jsonobject.tobean (JB, Accesstoken.class);
Object= "jsonstring
Jsonobject jb1 = Jsonobject.fromobject (AC);
System.out.println (Jb1.tostring ());
Java Json Object Mutual transfer