JSON data is more commonly used data type resolution, the advantages are not much to say. Take a look at the method:
public static Jsonobject getjsonobject (String url) {Jsonobject jsonobject = null;try {HttpClient HttpClient = new Defaulth Ttpclient (); HttpGet HttpGet = new HttpGet (URL); Httpparams httpparams = Httpclient.getparams (); Httpconnectionparams.setconnectiontimeout (Httpparams, 5000); HttpResponse response = Httpclient.execute (HttpGet); StringBuilder builder = new StringBuilder (); BufferedReader BufferedReader = new BufferedReader (New InputStreamReader (Response.getentity (). GetContent (), "Utf-8") ); for (String s = bufferedreader.readline (); s! = null; s = Bufferedreader.readline ()) {builder.append (s);} Jsonobject = new Jsonobject (builder.tostring ());} catch (Exception e) {e.printstacktrace (); jsonobject = null;} return jsonobject;}
The returned type is the Jsonobject type, and the subsequent addition of its own operation is possible.
Note: Depending on the amount of data requested, it may be time-consuming to use a thread to supportit, and you can use Asynctask with the following methods:
Take a look at my other blog post: Two ways to use Asynctask (with code)
How to get the JSON data to use it, you can refer to: JSON Learning note gson parsing JSON data (convenient, fast, including code)
Java requests JSON data from the network and parses JSON data----(self-creation, please specify)