Android programming experience sharing-JSON Learning Process

Source: Internet
Author: User

Let me talk about Android programming. When we first studied JSON, we all know that JSON, as a popular data exchange format, has many advantages, android web applications are widely used. Here I will record the process of learning JSON as follows:

This package has been introduced by default in the Android. jar package of Android. Here we can directly call it.
JSON has five basic types: object, array, value, string, and number.
Object
Take the following example:
{"Person": {"ID": 100, "Address": "Hanyang district, Wuhan", "name": "yang "}}

{} Represents an object, starting from {and ending with}. Before: represents the object name, and then represents the object value.
In the preceding example, the object "person" has a string of values {"ID": 100, "Address": "Hanyang district, Wuhan", "name": "yang "}.

According to the official explanation of JSON

Object
{}
{Members}
Members
Pair
Pair, members
Pair
String: Value

Similarly, members can include multiple key-value pairs, and multiple key-value pairs are separated by commas (,).
In the above example, the person value object contains objects with the object name ID and the value 100.

Array
The above object is identified by {}, while array is identified by []. What kind of data can an array contain? The following example shows how to use an array.
["Beijing", "Shanghai", "Wuhan"]

The array contains three values, "Beijing", "Shanghai", and "Wuhan", separated by commas.

Of course, we will use more complex examples in practical applications.
For example, [{"ID": 100, "Address": "Beijing", "name": "Zhang San" },{ "ID": 101, "Address ": "Wuhan", "name": "Li Si"}]
The array contains not strings, but objects. According to the official introduction, the value of a string can contain the following types:

Value
String
Number
Object
Array
True
False
Null
Value
According to the introduction of the above two types, we found that each center has value. As the basic type, value can be input into multiple types of values. In the above example, the value after each colon is value.

String
This type is similar to the string type in Java. It needs to use the "" package. The official website also mentioned that it can be escaped \.

Numebr
In the following example, the Data Type of 100 is number. Note that it does not include the octal and hexadecimal numbers.
{"ID": 100}

The following describes how to useCodeJSON

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.