问题描述
我在C语言编程方面经验不足,因此出现了问题。
我正在尝试通过指针将cJSON * body_json传递给函数int _parseJSON(const char* const body,cJSON* body_json)
。在此函数中,我想更改body_json并通过此指针将其返回,但是返回的值不正确(在下一个使用此body_json的函数中,我有错误)。
代码:
static int _parseJSON(const char* const body,cJSON* body_json)
{
body_json = cJSON_Parse(body);
if (body_json == NULL)
{
// Couldn't parse body to JSON. Probably wrong format given or no data.
const char* error_ptr = cJSON_GetErrorPtr();
if (error_ptr != NULL)
{
ESP_LOGE("Error in JSON string: %s",error_ptr);
}
cJSON_Delete(body_json);
return -1;
}
else{
return 0;
}
}
int parse_Feedback(const char * const body,FeedbackRequest *Feedback_data_request)
{
int status=0;
const char* email_key = "email";
// Parse body to json
cJSON* body_json=NULL;
status = _parseJSON(body,&body_json);
status = _parseString(body_json,&(Feedback_data_request->email),email_key);
return status;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)