Let me talk about my Android programming experience. When we first learned JSON, we all knew that JSON, as a popular data exchange format, has many advantages and is widely used in Android's WEB application. Here I will record the process of learning JSON as follows
This package has been introduced by default in Android packages, so we can call it directly
There are five basic types of JSON, namely object, array, value, string, number
Object
The following is an example
{"person":{"id":100,"address":"Hanyang District, Wuhan City","name":"yang"}}
{} represents an object object, starting with { and ending with }, :before represents the name of the object:after represents the value of the object
Then in the above example, the object represents the person, there is a string of values like this {"id":100,"address":"Hanyang District, Wuhan City","name":"yang"}
According to the official explanation of JSON
object
{}
{ members }
members
pair
pair , members
pair
string : value
In turn, members can include multiple key-value pairs, and the "," signs are separated by multiple key-value pairs.
Then the above example is to include objects with the object name id and the value 100 in the person value object.
Array
The above Object is identified by {}, while Array is identified by [], and Array can contain as an array? The following example is an example.
["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"}]
Now the array contains not a string, but an object. According to the official introduction, the value 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 has a Value in the middle. As a basic type, Value can pass in multiple types of values. In the above example, the value after each colon is Value
String
My understanding of this type is similar to the String type in our java. It requires the "" package. The official also mentioned that it can be escaped using \
Numebr
In the example below, the data type of 100 is Number. Note that it does not include octal and hexadecimal numbers.
{"id":100}
Here are the most commonly used usages. The next article will introduce how to use code to implement JSON
This package has been introduced by default in Android packages, so we can call it directly
There are five basic types of JSON, namely object, array, value, string, number
Object
The following is an example
{"person":{"id":100,"address":"Hanyang District, Wuhan City","name":"yang"}}
{} represents an object object, starting with { and ending with }, :before represents the name of the object:after represents the value of the object
Then in the above example, the object represents the person, there is a string of values like this {"id":100,"address":"Hanyang District, Wuhan City","name":"yang"}
According to the official explanation of JSON
object
{}
{ members }
members
pair
pair , members
pair
string : value
In turn, members can include multiple key-value pairs, and the "," signs are separated by multiple key-value pairs.
Then the above example is to include objects with the object name id and the value 100 in the person value object.
Array
The above Object is identified by {}, while Array is identified by [], and Array can contain as an array? The following example is an example.
["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"}]
Now the array contains not a string, but an object. According to the official introduction, the value 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 has a Value in the middle. As a basic type, Value can pass in multiple types of values. In the above example, the value after each colon is Value
String
My understanding of this type is similar to the String type in our java. It requires the "" package. The official also mentioned that it can be escaped using \
Numebr
In the example below, the data type of 100 is Number. Note that it does not include octal and hexadecimal numbers.
{"id":100}
Here are the most commonly used usages. The next article will introduce how to use code to implement JSON