It has to be said that the JSON format is really wonderful, fast and simplifies a lot of operations
Under Android, the Android SDK has encapsulated the entire JSON-related operation for us and is very easy to use
The following is the implementation of a standard JSON request:
[Java]View Plaincopyprint?
- HttpPost request = new HttpPost (URL);
- Encapsulates a JSON object first
- Jsonobject param = new Jsonobject ();
- Param.put ("name", "Rarnu");
- Param.put ("password", "123456");
- Bind to request Entry
- Stringentity se = new stringentity (param.tostring ());
- Request.setentity (SE);
- Send Request
- HttpResponse HttpResponse = new Defaulthttpclient (). Execute (Request);
- Gets the answer string, which is also a JSON format for saving data
- String retsrc = entityutils.tostring (Httpresponse.getentity ());
- Generating a JSON object
- Jsonobject result = new Jsonobject (RETSRC);
- String token = result.get ("token");
Remote access with JSON supported under Android (recommended this blog): http://marshal.easymorse.com/archives/1707
About the Android JSON write class--jsonwriter, easily generate JSON-formatted data: http://disanji.net/2011/03/05/android-3-0-json-jsonwriter/
Android JSON parsing sample code, daily Wiki widget:http://www.android123.com.cn/androidkaifa/664.html
The client sends data to the server, one with parameters in the URL, and one for the JSON data sending method (MOMO): http://henzil.easymorse.com/?p=241
Android accesses PHP to retrieve JSON data: http://blog.lrenwang.com/post/114/
How to send a request with an Android JSON object:
http://cn.webdiscussion.info/question/3027066/How to send a request to the Android-json object
Use JSON to implement HTTP requests under Android, plus a few examples!