mirror of
https://github.com/78/xiaozhi-esp32.git
synced 2026-01-14 09:17:20 +08:00
修复param.required()==false时可能触发未定义的问题 (#705)
This commit is contained in:
parent
aef527f7af
commit
0902ced1c4
@ -64,11 +64,18 @@ void Thing::Invoke(const cJSON* command) {
|
||||
throw std::runtime_error("Parameter " + param.name() + " is required");
|
||||
}
|
||||
if (param.type() == kValueTypeNumber) {
|
||||
param.set_number(input_param->valueint);
|
||||
if (cJSON_IsNumber(input_param)) {
|
||||
param.set_number(input_param->valueint);
|
||||
}
|
||||
} else if (param.type() == kValueTypeString) {
|
||||
param.set_string(input_param->valuestring);
|
||||
if (cJSON_IsString(input_param) || cJSON_IsObject(input_param) || cJSON_IsArray(input_param)) {
|
||||
std::string value_str = input_param->valuestring;
|
||||
param.set_string(value_str);
|
||||
}
|
||||
} else if (param.type() == kValueTypeBoolean) {
|
||||
param.set_boolean(input_param->valueint == 1);
|
||||
if (cJSON_IsBool(input_param)) {
|
||||
param.set_boolean(input_param->valueint == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user