赞
踩
- json解析对象:a.json
- {
- "name": "中国",
- "cities": [{
- "省份": "江苏",
- "城市": ["南京", "苏州"],
- "邮编": 123
- }, {
- "省份": "广东",
- "城市": ["深圳", "广州"],
- "邮编": 123
- }, {
- "省份": "湖北",
- "城市": ["武汉", "宜昌"],
- "邮编": 123
- }]
- }
- ```
-

- #include <stdio.h>
- #include "cJSON.h"
- #include <string.h>
-
- void cJSON_();
-
- int main()
- {
- cJSON* obj=cJSON_CreateObject();
- cJSON_AddStringToObject(obj,"name","中国");
-
- cJSON* arr=cJSON_CreateArray();
-
- cJSON* obj1=cJSON_CreateObject(); //江苏的
- cJSON_AddStringToObject(obj1,"省份","江苏");
- cJSON* arr1=cJSON_CreateArray();
- cJSON* item=cJSON_CreateString("南京");
- cJSON* item1=cJSON_CreateString("苏州");
- cJSON_AddItemToArray(a

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。