HTTP request using JSON in Android

Source: Internet
Author: User
I have to say that the JSON format is indeed very beautiful, fast, and simplified a lot of operations. In Android, the android SDK has encapsulated the entire JSON-related operation for us, the following is the implementation process of a standard JSON request: httppost request = new httppost (URL); // encapsulate a JSON object jsonobject Param = new jsonobject (); Param. put ("name", "rarnu"); Param. put ("password", "123456"); // bind to the request entry stringentity Se = new stringentity (Param. tostring (); Request. setentity (SE); // send the request httpresponse = new defaulthttpclient(.exe cute (request); // The response string, which is also a string retsrc = entityutils stored in JSON format. tostring (httpresponse. getentity (); // generate JSON object jsonobject result = new jsonobject (retsrc); string token = result. get ("token ");
Related Article

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.