Ace teaches you one step at a to do Android news client (iii) JSON data parsing

Source: Internet
Author: User
<span id="Label3"></p><p><p>For the server side, the data format returned to the client is generally divided into three formats such as html, xml, and json, and now let's explain the JSON point of knowledge,</p></p><p><p>1 How to parse our JSON data through the two JSON parsing libraries of Json-lib and gson,</p></p><p><p>2 and how to parse the JSON data from the server side in our Android client and update it to the Ui. (in the next Article)</p></p><p><p></p></p><p><p><strong><span style="font-size: 16px;">first, what is JSON</span></strong></p></p><p><p>JSON (Javascript Object Notation) is a lightweight data interchange format, as compared to xml, because parsing XML is more complex and requires writing large pieces of code, therefore, the data Interchange format of client and server is often exchanged through Json. Especially for Web development, the JSON data format can be parsed directly by JavaScript on the Client.</p></p><p><p>JSON has two data structures, one is an unordered Jsonobject object in the form of (key/value), and an object begins with "{" (the left Curly Brace) and "}" (the closing curly Brace) ends. Each "name" is followed by a ":" (colon); "' name/value ' pair ' is separated by", "(comma).</p></p><p><p></p></p><p><p>For example: {"name": "xiaoluo"}, This is the simplest JSON object, for this data format, the key value must be a string type, and for value, it can be a string, number, object, array and other data types:</p></p><p><p></p></p><p><p>Another data format is the set of ordered values, which is known as jsonarray, an ordered collection of value (s). An array begins with "[" (the left square bracket), and "]" (the right square bracket) ends. Use "," (comma) to separate values.</p></p><p><p></p></p><p><p></p></p><p><p>More about JSON data format can participate in Json's official website, http://www.json.org/json-zh.html, We mainly talk about how to parse the data sent by the server</p></p><p><p><strong>Now put on an API interface you can use it.</strong></p></p><pre>Http://www.imooc.com/api/teacher?type=4&num=30<br><br>Thank you Mu class network Mu class network is really a fried chicken stick website, Beginner Intermediate Advanced tutorials have (good thing of course to amway!) I have heard the Heima of the messenger of the birds of the class is very fast and the content of a lot, but not special, so bingo here again Amway again;<br><br>Then chrome can install Plug-ins json-xx no words Baidu search JSON online analysis of the site can see the clear structure is a<br><br><br>{"data": [{<span class="json_key"><span class="json_key"> "id": <span class="json_number">1, <br>              <span class="json_key"> "name": <span class="json_string"> "tony teacher Talk shell--environment variable profile", <br>             <span class="json_key"> "picSmall": Span class= "json_string" > "http://img.mukewang.com/55237dcc0001128c06000338-300-170.jpg", <br>              <span class="json_key"> "picbig": <span class="json_string"> "http://img.mukewang.com/55237dcc0001128c06000338.jpg", <br>              <span class="json_key"> "description": <span class="json_string" to bring you the environment variable profile in shell, <br>              <span class="json_key"> "learner": <span class="json_number">12312 </span> </span> </span> </span> </span></span></span></span></span></span></span></span>},{},{},{},{},{}]<br><br><br>From above the little science knows it's a Jsonarray</pre><p><p><strong><span style="font-size: 16px;">The following evening after dinner to write</span></strong></p></p><p><p></p></p><p><p></p></p><pre><pre><br><br><br><br><br><br><br><br><br><br><br></pre></pre><p><p></p></p><p><p>Ace teaches you one step at a to do Android news client (iii) JSON data parsing</p></p></span>

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.