{ "action":"set", "mac":["00:17:62:51:29:21"], "password":"admin", "dataList": [{ "url_path":"/apply.cgi", "method":"POST", "Template":"register", "data": { "action":"mode_set", "mode":"1", "username":"prouser", "password":"admin" } }] }
{ "action":"mode_set", "mode":1 }
cJSON *JsData = cJSON_CreateObject(); cJSON_AddStringToObject(JsData, "action", "mode_set"); cJSON_AddNumberToObject(JsData, "mode", 1);
char c1Data[100] = " { \"action\":\"cloud_set\", \"mode\":1 } " cJSON *JsData = NULL; cJSON *pValue = NULL; JsData = cJSON_Parse(c1Data); pValue = cJSON_GetObjectItem(JsData, "action"); printf("action : %s \r\n", pValue->valuestring); pValue = cJSON_GetObjectItem(JsData, "mode"); printf("mode : %d \r\n", pValue->valuestring);
cJSON_AddBoolToObject(object, key, value); cJSON_AddFalseToObject(object, key); cJSON_AddTrueToObject(object, key); cJSON_AddNullToObject(object, null);
{ "action":"mode_set", "mode":1 "datalist": { "username":"admin", "password":"admin" } }
cJSON *JsDataList = cJSON_CreateObject(); cJSON_AddItemToObject(JsData, JsDataList); cJSON_AddStringToObject(JsDataList, "username", "admin"); cJSON_AddStringToObject(JsDataList, "password", "admin");
cJSON *JsDataList = NULL; cJSON *pValue = NULL; JsDataList = cJSON_GetObjectItem(JsData, "datalist"); pValue = cJSON_GetObjectItem(datalist, "username"); printf("username : %s \r\n", pValue->valuestring); pValue = cJSON_GetObjectItem(datalist, "password"); printf("password : %s \r\n", pValue->valuestring);
{ "action":"mode_set", "mode":1, "datalist": { "username":"admin", "password":"admin" } "register": ["{ "status":"0", "msg":"Success." }"] }
cJSON *JsRegisterArr = cJSON_CreateArray(); cJSON *JsRegisterObj = cJSON_CreateObject(); cJSON_AddItemToObject(JsData, "register", JsRegisterArr); cJSON_AddItemToArray(JsRegisterArr, JsRegisterObj); cJSON_AddStringToObject(JsRegisterObj, "status", "0"); cJSON_AddStringToObject(JsRegisterObj, "msg", "Success");
cJSON *JsRegisterArr = NULL; cJSON *JsRegisterObj = NULL; cJSON *pValue = NULL; UINT4 u4DataSize = 0; JsRegisterArr = cJSON_GetObjectItem(JsData, "register"); u4DataSize = cJSON_GetArraySize(JsRegisterArr); for (UINT4 u4Index = 0; u4Index < u4DataSize; u4Index ++) { JsRegisterObj = cJSON_GetArrayItem(JsRegisterArr, u4Index) pValue = cJSON_GetObjectItem(JsRegisterObj, "status"); printf("status : %s \r\n", pValue->valuestring); pValue = cJSON_GetObjectItem(JsRegisterObj, "msg"); printf("msg : %s \r\n", pValue->valuestring); }
{ "action":"mode_set", "mode":1 "datalist": { "username":"admin", "password":"admin" } }
cJSON *JsDataList = NULL; cJSON_ReplaceItemInObject(JsDataList, "password", "admin123");
cJSON_DeleteItemFromObject(JsDataList, "password");
UINT1 *pu1Data = NULL; UINT1 au1Data[1024] = {0}; pu1Data = cJSON_PrintUnformatted(JsData); SPRINTF(au1Data, pu1Data);
cJSON_Parse(); cJSON_CreateObject(); cJSON_CreateArray(); cJSON_Print(); cJSON_PrintUnformatted();
cJSON_Delete(); cJSON_free();
cJSON *JsData = NULL; JsData = cJSON_CreateObject(); if (JsData == NULL) return FAILURE;