JSON

一.特点

    1.JavaScript Object Notation

    2.一种轻量级的数据交互格式

二.格式

    1.[ ] 数组:[value1, value2, value3...]

    2.{ } 对象:{key1:value1, key2:value2, key3:value3,...}

      1-key:字符串,表示对象的属性

      2-value:表示属性的值

         数据类型:数值,字符串,null,json数组,json对象。

三.API

   1.Android原生

   2.第三方框架

 

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <LinearLayout xmlns:andro
 3     xmlns:tools="http://schemas.android.com/tools"
 4     android:layout_width="match_parent"
 5     android:layout_height="match_parent"
 6     android:paddingBottom="@dimen/activity_vertical_margin"
 7     android:paddingLeft="@dimen/activity_horizontal_margin"
 8     android:paddingRight="@dimen/activity_horizontal_margin"
 9     android:paddingTop="@dimen/activity_vertical_margin"
10     tools:context="com.hanqi.testapp3.TestActivity4"
11     android:orientation="vertical">
12 
13     <Button
14         android:layout_width="match_parent"
15         android:layout_height="wrap_content"
16         android:text="Android原生解析JSON转对象"
17         android:onClick="bt1_OnClick"/>
18 
19     <Button
20         android:layout_width="match_parent"
21         android:layout_height="wrap_content"
22         android:text="Gson解析JSON转对象"
23         android:onClick="bt2_OnClick"/>
24 
25     <Button
26         android:layout_width="match_parent"
27         android:layout_height="wrap_content"
28         android:text="Android原生解析JSON转集合"
29         android:onClick="bt3_OnClick"/>
30 
31     <Button
32         android:layout_width="match_parent"
33         android:layout_height="wrap_content"
34         android:text="Gson解析JSON转集合"
35         android:onClick="bt4_OnClick"/>
36 
37     <Button
38         android:layout_width="match_parent"
39         android:layout_height="wrap_content"
40         android:text="Gson解析JSON之对象转JSON"
41         android:onClick="bt5_OnClick"/>
42 
43     <Button
44         android:layout_width="match_parent"
45         android:layout_height="wrap_content"
46         android:text="Gson解析JSON之集合转JSON"
47         android:onClick="bt6_OnClick"/>
48 
49 
50 
51 
52     <EditText
53         android:layout_width="match_parent"
54         android:layout_height="200dp"
55         android:/>
56 
57 
58 </LinearLayout>
59 
60 .xml
.xml

相关文章: