【ESP8266】使用ESP8266 NONOS SDK的JSON API

2016年9月30日更新:本人移植了cJSON到ESP8266的NONOS SDK,详情可以查看这篇文章:

http://blog.csdn.net/yannanxiu/article/details/52713746

===============================================

一、概述

这篇文章是讲解如何用ESP8266官方提供的Json接口处理数据。


首先要在esp_iot_sdk/example/IoT_Demo示例目录下找到user_json.cuser_json.h,把这两个文件包含进自己的工程。


查看json.h文件,里面有一下宏定义

[cpp]  view plain  copy
 print ?
  1. #define JSON_TYPE_ARRAY '['  
  2. #define JSON_TYPE_OBJECT '{'  
  3. #define JSON_TYPE_PAIR ':'  
  4. #define JSON_TYPE_PAIR_NAME 'N' /* for N:V pairs */  
  5. #define JSON_TYPE_STRING '"'  
  6. #define JSON_TYPE_INT 'I'  
  7. #define JSON_TYPE_NUMBER '0'  
  8. #define JSON_TYPE_ERROR 0  

后面的例程都是用此宏定义来判断Json的键值的数据类型。


二、生成一个Json

下面给出生成Json树的示例,生成的JSON树get_h内容如下:"hi":{"hello":"world"}

[cpp]  view plain  copy
 print ?
  1. /***************************************************/  
  2. LOCAL int ICACHE_FLASH_ATTR  
  3. hello_get(struct jsontree_context *js_ctx)  
  4. {  
  5.     const char *path = jsontree_path_name(js_ctx, js_ctx->depth - 1);  
  6.     char string[32];  
  7.   
  8.     if (os_strncmp(path, "hello", 5) == 0) {  
  9.         os_sprintf(string, "world");  
  10.     }  
  11.   
  12.     jsontree_write_string(js_ctx, string);  
  13.   
  14.     return 0;  
  15. }  
  16.   
  17. LOCAL struct jsontree_callback hello_callback =  
  18.     JSONTREE_CALLBACK(hello_get, NULL);  
  19.   
  20. JSONTREE_OBJECT(get_hello,  
  21.                 JSONTREE_PAIR("hello", &hello_callback));  
  22. JSONTREE_OBJECT(get_h,  
  23.                 JSONTREE_PAIR("hi", &get_hello));  

其中宏定义JSONTREE_OBJECT是生成一个JSON数的对象,第一个参数是该对象的名称(get_h),JSONTREE_PAIR是生成一个键值对的宏。

JSONTREE_CALLBACL是生成一个回调指针的宏,该宏有两个参数,第一个参数是设置读取JSON树的值的函数,这里为hello_get函数,第二个参数是设置写入JSON树的值的函数,这里没有用到,为NULL。

hello_get是生成JSON树的值的函数。其中用os_strncnp进行Json键的判断,如果键为hello,则对该键写入"world"值。

这里生成的JSON是:"hi":{"hello","world"},hi是用来调用后面Json数据的:


[cpp]  view plain  copy
 print ?
  1. #define BUF_LENTH 64  
  2. LOCAL char buf[BUF_LENTH];  
  3.     json_ws_send((struct jsontree_value *)&get_h, "hi", buf);  
  4.     os_printf("%s\n",buf);  

使用json_ws_send函数可以把hi后面的数据写入buf,json_ws_send函数在IoT_demo例程中的user_json.c文件里。

最后打印结果是:

{

"hello":"world"

}


三、生成一个温湿度Json数据

下面是一个生成温湿度的例程:

[cpp]  view plain  copy
 print ?
  1. /********************DHT11***********************/  
  2. LOCAL int ICACHE_FLASH_ATTR  
  3. dht11_get(struct jsontree_context *js_ctx)  
  4. {  
  5.     const char *path = jsontree_path_name(js_ctx, js_ctx->depth - 1);  
  6.     char string[32];  
  7.   
  8.     if (os_strncmp(path, "temp", 4) == 0)  
  9.     {  
  10.         //os_sprintf(string, "%d",temperture);  
  11.         os_sprintf(string,"25");  
  12.     }  
  13.     else if(os_strncmp(path, "hum", 3) == 0)  
  14.     {  
  15.         //os_sprintf(string, "%d",hum);  
  16.         os_sprintf(string,"40");  
  17.     }  
  18.   
  19.     jsontree_write_string(js_ctx, string);  
  20.   
  21.     return 0;  
  22. }  
  23.   
  24. LOCAL struct jsontree_callback dht11_callback =  
  25.     JSONTREE_CALLBACK(dht11_get, NULL);  
  26.   
  27. JSONTREE_OBJECT(get_dht11,  
  28.                 JSONTREE_PAIR("temp", &dht11_callback),  
  29.         JSONTREE_PAIR("hum", &dht11_callback));  
  30. JSONTREE_OBJECT(DHT11JSON,  
  31.                 JSONTREE_PAIR("dht11", &get_dht11));  
  32.   
  33. //返回DHT11数据的json格式  
  34. char* ICACHE_FLASH_ATTR  
  35. get_dht11_json(void)  
  36. {  
  37.     static char dht11_buf[64];  
  38.     os_memset(dht11_buf,0,64);      //清空  
  39.     json_ws_send((struct jsontree_value *)&DHT11JSON, "dht11", dht11_buf);  
  40.     return dht11_buf;  
  41. }  


之后在user_init入口函数写一个打印函数

[cpp]  view plain  copy
 print ?
  1. os_printf(get_dht11_json());  

就可以看到串口打印出

{
"temp":"25",
"hum":"40"
}


四、一个完整的生成Json数据示例

下面是一个完整的生成Json数据的示例,可以生成字符串、整型值、数组、Json对象的Value。

Json数据的生成最重要的是理解函数回调机制,看代码要从下往上看,如果看官接触过异步回调机制的代码,阅读起来可能会有一种相似的感觉。


[cpp]  view plain  copy
 print ?
  1. #include "user_json.h"  
  2. #include "ets_sys.h"  
  3. #include "os_type.h"  
  4. #include "osapi.h"  
  5. #include "mem.h"  
  6. #include "user_interface.h"  
  7.   
  8. LOCAL int ICACHE_FLASH_ATTR  
  9. jsonTree_get(struct jsontree_context *js_ctx)  
  10. {  
  11.     const char *path = jsontree_path_name(js_ctx, js_ctx->depth - 1);  
  12.       
  13.     //生成"String":"data"  
  14.     if (os_strncmp(path, "String", os_strlen("String")) == 0) {  
  15.         jsontree_write_string(js_ctx, "data");  
  16.     //生成"Integer":1  
  17.     } else if (os_strncmp(path, "Integer", os_strlen("Integer")) == 0) {  
  18.         jsontree_write_int(js_ctx, 1);  
  19.     //生成"Array":[0,1,2]  
  20.     } else if (os_strncmp(path, "Array", os_strlen("Array")) == 0) {  
  21.         int array[3] = {0,1,2};  
  22.         jsontree_write_atom(js_ctx, "[");  
  23.         jsontree_write_int_array(js_ctx, array, 3);  
  24.         jsontree_write_atom(js_ctx, "]");  
  25.     }  
  26.   
  27.     return 0;  
  28. }  
  29.   
  30. LOCAL int ICACHE_FLASH_ATTR  
  31. jsonArray_get(struct jsontree_context *js_ctx)  
  32. {  
  33.     const char *path = jsontree_path_name(js_ctx, js_ctx->depth - 1);  
  34.   
  35.     if (os_strncmp(path, "K1", os_strlen("K2")) == 0) {  
  36.         jsontree_write_string(js_ctx, "D1");  
  37.     } else if (os_strncmp(path, "K2", os_strlen("K2")) == 0) {  
  38.         jsontree_write_string(js_ctx, "D2");  
  39.     } else if (os_strncmp(path, "K3", os_strlen("K3")) == 0) {  
  40.         jsontree_write_string(js_ctx, "D3");  
  41.     }  
  42.   
  43.     return 0;  
  44. }  
  45.   
  46. //初始化一个Json数据回调函数  
  47. //JSONTREE_CALLBACK第一个参数为生成Json数据的函数指针,第二个为获取Json数据的函数指针  
  48. LOCAL struct jsontree_callback jsonArrayCallback =  
  49.     JSONTREE_CALLBACK(jsonArray_get, NULL);  
  50.   
  51. JSONTREE_OBJECT(jsonArrayData,  
  52.                 JSONTREE_PAIR("K1", &jsonArrayCallback),  
  53.                 JSONTREE_PAIR("K2", &jsonArrayCallback),  
  54.         JSONTREE_PAIR("K3", &jsonArrayCallback));  
  55. JSONTREE_ARRAY(jsonArray,  
  56.                JSONTREE_PAIR_ARRAY(&jsonArrayData),  
  57.                JSONTREE_PAIR_ARRAY(&jsonArrayData),  
  58.                JSONTREE_PAIR_ARRAY(&jsonArrayData));  
  59.   
  60. LOCAL struct jsontree_callback jsonCallback =  
  61.     JSONTREE_CALLBACK(jsonTree_get, NULL);  
  62.   
  63. JSONTREE_OBJECT(jsonObject,  
  64.                 JSONTREE_PAIR("String", &jsonCallback),  
  65.                 JSONTREE_PAIR("Integer", &jsonCallback),  
  66.                 JSONTREE_PAIR("JsonArray", &jsonArray));  
  67. JSONTREE_OBJECT(jsonTestTrees,  
  68.                 JSONTREE_PAIR("String", &jsonCallback),    //生成一个String键,并设置一个回调函数  
  69.         JSONTREE_PAIR("Integer", &jsonCallback),   //生成一个Integer键,并设置一个回调函数  
  70.         JSONTREE_PAIR("Array", &jsonCallback),     //生成一个Array键,并设置一个回调函数  
  71.         JSONTREE_PAIR("JsonObject", &jsonObject)); //生成一个jsonObject键,并设置一个Json对象  
  72. JSONTREE_OBJECT(jsonTestTree,  
  73.                 JSONTREE_PAIR("jsonTest", &jsonTestTrees));  
  74.   
  75.   
  76. #define LENGTH 512  
  77. char* getJsonTree(void)  
  78. {  
  79.     static char jsonbuf[LENGTH];  
  80.     os_memset(jsonbuf, 0, LENGTH);      //初始化字符串  
  81.     json_ws_send((struct jsontree_value *)&jsonTestTree, "jsonTest", jsonbuf);  
  82.   
  83.     //os_printf("%s\n", jsonbuf);  
  84.   
  85.     return jsonbuf;  
  86. }  




该代码会生成如下Json数据:

[plain]  view plain  copy
 print ?
  1. {  
  2.     "String": "data",  
  3.     "Integer": 1,  
  4.     "Array": [  
  5.         0,  
  6.         1,  
  7.         2  
  8.     ],  
  9.     "JsonObject": {  
  10.         "String": "data",  
  11.         "Integer": 1,  
  12.         "JsonArray": [  
  13.             {  
  14.                 "K1": "D1",  
  15.                 "K2": "D2",  
  16.                 "K3": "D3"  
  17.             },  
  18.             {  
  19.                 "K1": "D1",  
  20.                 "K2": "D2",  
  21.                 "K3": "D3"  
  22.             },  
  23.             {  
  24.                 "K1": "D1",  
  25.                 "K2": "D2",  
  26.                 "K3": "D3"  
  27.             }  
  28.         ]  
  29.     }  
  30. }  



五、从Json提取数据

如果网络发送一串JSON数据给ESP8266,如何使用该接口获取JSON的键值呢?下面给出示例代码,这里使用的数据是上面生成的数据。

其中第二次的Json对象数据获取很麻烦,所以传给8266的Json尽量用一层,如果是数组里面再有Json对象,那么就更麻烦了,具体请看代码。

[cpp]  view plain  copy
 print ?
  1. LOCAL int ICACHE_FLASH_ATTR  
  2. jsonTree_set(struct jsontree_context *js_ctx, struct jsonparse_state *parser)  
  3. {  
  4.     int type;  
  5.   
  6.     while ((type = jsonparse_next(parser)) != 0) {  
  7.         //如果是KEY类型  
  8.         if (type == JSON_TYPE_PAIR_NAME) {  
  9.             char buffer[64];  
  10.             os_bzero(buffer, 64);  
  11.   
  12.             if (jsonparse_strcmp_value(parser, "String") == 0) {  
  13.                 jsonparse_next(parser); //返回的是冒号字符  
  14.                 type = jsonparse_next(parser);  //返回的是双引号字符  
  15.                 os_printf("String Value type = %c\n", type);    // = "  
  16.   
  17.                 //如果Value是字符串类型,则读取数据到buffer  
  18.                 if (JSON_TYPE_STRING == type){  //#define JSON_TYPE_STRING '"'  
  19.                     jsonparse_copy_value(parser, buffer, sizeof(buffer));  
  20.                     os_printf("String Value = %s\n", buffer);  
  21.                 }  
  22.   
  23.             } else if (jsonparse_strcmp_value(parser, "Integer") == 0) {  
  24.                 jsonparse_next(parser);  
  25.                 type = jsonparse_next(parser);  
  26.   
  27.   
  28.                 os_printf("Integer Value type = %c\n", type);   // = 0  
  29.                 //如果Value是数值类型  
  30.                 if(JSON_TYPE_NUMBER == type){   //#define JSON_TYPE_NUMBER '0'  
  31.                     //jsonparse_copy_value(parser, buffer, sizeof(buffer));  
  32.                     int num = 0;  
  33.                     num = jsonparse_get_value_as_int(parser);  
  34.                     os_printf("Integer Value = %d\n", num);     // = 1  
  35.                 }  
  36.             } else if (jsonparse_strcmp_value(parser, "Array") == 0) {  
  37.                 jsonparse_next(parser); //跳过冒号  
  38.                 type = jsonparse_next(parser);  
  39.                 os_printf("Array Value type = %c\n", type);     // = [  
  40.   
  41.                 //如果Value是数组类型  
  42.                 if(JSON_TYPE_ARRAY == type){    //#define JSON_TYPE_ARRAY '['  
  43.                     //jsonparse_copy_value(parser, buffer, sizeof(buffer));  
  44.                     int length = jsonparse_get_len(parser);  
  45.                     os_printf("Array Length = %d\n", length);   //= 5, 数据是[0,1,2],可能把逗号也算在内  
  46.   
  47.                     int i;  
  48.                     int num = 100;  
  49.                     //循环读取数组的数据  
  50.                     for(i=0; i<length; i++){  
  51.                         type = jsonparse_next(parser);  
  52.                         // 如果是逗号,则直接打印, 如果是数值则打印0  
  53.                         os_printf("Array[%d] type = %c ", i, type);  
  54.   
  55.                         //如果是数值类型,则转换成int并打印出来  
  56.                         if(JSON_TYPE_NUMBER==type){  
  57.                             num = jsonparse_get_value_as_int(parser);  
  58.                             os_printf("Array[%d] = %d\n", i, num);  
  59.                         }  
  60.                         //后面可以添加else if判断是否是其他类型  
  61.                         //比如 else if(JSON_TYPE_OBJECT==type),判断是否是Json对象  
  62.                         else{  
  63.                             os_printf("\n");  
  64.                         }  
  65.                     }  
  66.                 }  
  67.             }  
  68. #if 1  
  69.             else if (jsonparse_strcmp_value(parser, "JsonObject") == 0) {  
  70.                 jsonparse_next(parser); //跳过冒号  
  71.                 type = jsonparse_next(parser);  
  72.                 os_printf("JsonObject Value type = %c\n", type);        // = {  
  73.   
  74.                 if(JSON_TYPE_OBJECT == type){   //#define JSON_TYPE_OBJECT '{'  
  75.                     int length = jsonparse_get_len(parser);  
  76.                     os_printf("JsonObject Length = %d\n", length);  
  77.   
  78.                     //char temp[128] = {0};  
  79.                     //jsonparse_copy_value(parser, temp, 128);  
  80.                     //os_printf("JsonObject Value = %s\n", temp);  
  81.   
  82.                     //循环读取数据  
  83.                     int i = 0;  
  84.                     //for(i=0; i<length; i++){  
  85.                     while(type != '}'){  
  86.                         i++;  
  87.                         type = jsonparse_next(parser);  
  88.   
  89.                         os_printf("JsonObject[%d] type = %c", i, type);  
  90.                         os_printf("\n");  
  91.                         //os_memset(temp, 0, 128);  
  92.                         //jsonparse_copy_value(parser, temp, 128);  
  93.                         //os_printf("JsonObject Value = %s\n", temp);  
  94.                         //读取第二层的Json对象的数据  
  95.                         jsonObject_set(parser);  
  96.                     }  
  97.                 }  
  98.   
  99.             }  
  100. #endif  
  101.         }  
  102.     }  
  103.   
  104.     return 0;  
  105. }  
  106.   
  107. LOCAL int ICACHE_FLASH_ATTR  
  108. jsonObject_set(struct jsonparse_state *parser)  
  109. {  
  110.     int type = jsonparse_get_type(parser);  
  111.     int vtype = parser->vtype;  
  112.     //os_printf("json Object type=%c, vtype=%c\n", type, vtype);  
  113.     char buffer[64];  
  114.     os_bzero(buffer, 64);  
  115.   
  116.     //如果是KEY类型  
  117.     if (vtype == JSON_TYPE_PAIR_NAME) {  
  118.        if (jsonparse_strcmp_value(parser, "String") == 0) {  
  119.             jsonparse_next(parser); //返回的是冒号字符  
  120.             type = jsonparse_next(parser);  //返回的是双引号字符  
  121.             //os_printf("jsonObject String Value type = %c\n", type);   // = "  
  122.   
  123.             //如果Value是字符串类型,则读取数据到buffer  
  124.             if (JSON_TYPE_STRING == type){  //#define JSON_TYPE_STRING '"'  
  125.                 jsonparse_copy_value(parser, buffer, sizeof(buffer));  
  126.                 os_printf("jsonObject String Value = %s\n", buffer);  
  127.             }  
  128.   
  129.         } else if (jsonparse_strcmp_value(parser, "Integer") == 0) {  
  130.             jsonparse_next(parser);  
  131.             type = jsonparse_next(parser);  
  132.             //os_printf("jsonObject Integer Value type = %c\n", type);  // = 0  
  133.             //如果Value是数值类型  
  134.             if(JSON_TYPE_NUMBER == type){   //#define JSON_TYPE_NUMBER '0'  
  135.                 //jsonparse_copy_value(parser, buffer, sizeof(buffer));  
  136.                 int num = 0;  
  137.                 num = jsonparse_get_value_as_int(parser);  
  138.                 os_printf("jsonObject Integer Value = %d\n", num);      // = 1  
  139.             }  
  140.         } else if (jsonparse_strcmp_value(parser, "JsonArray") == 0) {  
  141.             jsonparse_next(parser);  
  142.             type = jsonparse_next(parser);  
  143.             //os_printf("jsonObject Integer Value type = %c\n", type);  // = 0  
  144.             //如果Value是数值类型  
  145.             if(JSON_TYPE_ARRAY == type){  
  146.                 //jsonparse_copy_value(parser, buffer, sizeof(buffer));  
  147.                 //os_printf("buffer = %s\n", buffer);  
  148.                 int length = jsonparse_get_len(parser);  
  149.                 os_printf("JsonArray Length = %d\n", length);   //读取出来的长度不准确  
  150.   
  151.                 //循环读取Json对象数据  
  152.                 int i = 0;  
  153.                 //for(i=0; i<length; i++){  
  154.                 while(type != ']'){i++;     //用']'判断是否达到数组末尾  
  155.   
  156.                     type = jsonparse_next(parser);  
  157.   
  158.                     os_printf("JsonArray[%d] type = %c", i, type);  
  159.                     os_printf("\n");  
  160.   
  161.                     //如果是KEY类型  
  162.                     if (type == JSON_TYPE_PAIR_NAME) {  
  163.                        if (jsonparse_strcmp_value(parser, "K1") == 0) {  
  164.                             jsonparse_next(parser); //返回的是冒号字符  
  165.                             type = jsonparse_next(parser);  //返回的是双引号字符  
  166.                             //os_printf("K1 Value type = %c\n", type);  // = "  
  167.   
  168.                             //如果Value是字符串类型,则读取数据到buffer  
  169.                             if (JSON_TYPE_STRING == type){  //#define JSON_TYPE_STRING '"'  
  170.                                 os_bzero(buffer, 64);  
  171.                                 jsonparse_copy_value(parser, buffer, sizeof(buffer));  
  172.                                 os_printf("K1 = %s\n", buffer);  
  173.                             }  
  174.                         } else if(jsonparse_strcmp_value(parser, "K2") == 0){  
  175.                             jsonparse_next(parser); //返回的是冒号字符  
  176.                             type = jsonparse_next(parser);  //返回的是双引号字符  
  177.                             //如果Value是字符串类型,则读取数据到buffer  
  178.                             if (JSON_TYPE_STRING == type){  //#define JSON_TYPE_STRING '"'  
  179.                                 os_bzero(buffer, 64);  
  180.                                 jsonparse_copy_value(parser, buffer, sizeof(buffer));  
  181.                                 os_printf("K2 = %s\n", buffer);  
  182.                             }  
  183.                         } else if(jsonparse_strcmp_value(parser, "K3") == 0){  
  184.                             jsonparse_next(parser); //返回的是冒号字符  
  185.                             type = jsonparse_next(parser);  //返回的是双引号字符  
  186.                             //如果Value是字符串类型,则读取数据到buffer  
  187.                             if (JSON_TYPE_STRING == type){  //#define JSON_TYPE_STRING '"'  
  188.                                 os_bzero(buffer, 64);  
  189.                                 jsonparse_copy_value(parser, buffer, sizeof(buffer));  
  190.                                 os_printf("K3 = %s\n", buffer);  
  191.                             }  
  192.                         }  
  193.                     }  
  194.                 }  
  195.             }  
  196.         }  
  197.     }  
  198. }  
  199.   
  200.   
  201.   
  202. LOCAL int ICACHE_FLASH_ATTR  
  203. jsonArray_set(struct jsontree_context *js_ctx, struct jsonparse_state *parser)  
  204. {  
  205.     int type;  
  206.   
  207.     while ((type = jsonparse_next(parser)) == 0) {  
  208.         //如果是KEY类型  
  209.         if (type == JSON_TYPE_PAIR_NAME) {  
  210.             char buffer[64];  
  211.             os_bzero(buffer, 64);  
  212.   
  213.             if (jsonparse_strcmp_value(parser, "K1") == 0) {  
  214.                 if (JSON_TYPE_STRING == type){  //#define JSON_TYPE_STRING '"'  
  215.                     jsonparse_copy_value(parser, buffer, sizeof(buffer));  
  216.                     os_printf("K1 Value = %s\n", buffer);  
  217.                 }  
  218.             } else if (jsonparse_strcmp_value(parser, "K2")==0) {  
  219.                 if (JSON_TYPE_STRING == type){  //#define JSON_TYPE_STRING '"'  
  220.                     jsonparse_copy_value(parser, buffer, sizeof(buffer));  
  221.                     os_printf("K2 Value = %s\n", buffer);  
  222.                 }  
  223.             } else if (jsonparse_strcmp_value(parser, "K3")==0) {  
  224.                 if (JSON_TYPE_STRING == type){  //#define JSON_TYPE_STRING '"'  
  225.                     jsonparse_copy_value(parser, buffer, sizeof(buffer));  
  226.                     os_printf("K3 Value = %s\n", buffer);  
  227.                 }  
  228.             }  
  229.         }  
  230.     }  
  231.   
  232.     return 0;  
  233. }  
  234.   
  235.   
  236.   
  237.   
  238. void ICACHE_FLASH_ATTR  
  239. setJsonTree(char *json)  
  240. {  
  241.     struct jsontree_context js;  
  242.   
  243.     jsontree_setup(&js, (struct jsontree_value *)&jsonTestTree, json_putchar);  
  244.     json_parse(&js, json);  
  245. }  
  246.   
  247. void ICACHE_FLASH_ATTR  
  248. setJsonObject(char *json)  
  249. {  
  250.     struct jsontree_context js;  
  251.   
  252.     jsontree_setup(&js, (struct jsontree_value *)&jsonObject, json_putchar);  
  253.     json_parse(&js, json);  
  254. }  


最后要修改一下这条语句,给jsonCallback第二个参数添加jsonTree_set。

[cpp]  view plain  copy
 print ?
  1. LOCAL struct jsontree_callback jsonCallback =  
  2.     JSONTREE_CALLBACK(jsonTree_get, jsonTree_set);  

打印:

String Value type = "
String Value = data
Integer Value type = 0
Integer Value = 1
Array Value type = [
Array Length = 5
Array[0] type = 0 Array[0] = 0
Array[1] type = , 
Array[2] type = 0 Array[2] = 1
Array[3] type = , 
Array[4] type = 0 Array[4] = 2
JsonObject Value type = {
JsonObject Length = 10
JsonObject[1] type = N
jsonObject String Value = data
JsonObject[2] type = ,
JsonObject[3] type = N
jsonObject Integer Value = 1
JsonObject[4] type = ,
JsonObject[5] type = N
JsonArray Length = 9
JsonArray[1] type = {
JsonArray[2] type = N
K1 = D1
JsonArray[3] type = ,
JsonArray[4] type = N
K2 = D2
JsonArray[5] type = ,
JsonArray[6] type = N
K3 = D3
JsonArray[7] type = }
JsonArray[8] type = ,
JsonArray[9] type = {
JsonArray[10] type = N
K1 = D1
JsonArray[11] type = ,
JsonArray[12] type = N
K2 = D2
JsonArray[13] type = ,
JsonArray[14] type = N
K3 = D3
JsonArray[15] type = }
JsonArray[16] type = ,
JsonArray[17] type = {
JsonArray[18] type = N
K1 = D1
JsonArray[19] type = ,
JsonArray[20] type = N
K2 = D2
JsonArray[21] type = ,
JsonArray[22] type = N
K3 = D3
JsonArray[23] type = }
JsonArray[24] type = ]
JsonObject[6] type = }


六、代码下载

如果想要示例代码,可以从这里下载:http://download.csdn.net/detail/u012163234/9638834



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值