mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-27 04:49:47 +01:00
update:增加mcp调用后数据类型的判断
This commit is contained in:
parent
cbb293e7fa
commit
b2ddf060c9
1 changed files with 14 additions and 1 deletions
|
|
@ -805,7 +805,20 @@ public class DeviceServiceImpl extends BaseServiceImpl<DeviceDao, DeviceEntity>
|
||||||
if (firstContent != null && "text".equals(firstContent.getStr("type"))) {
|
if (firstContent != null && "text".equals(firstContent.getStr("type"))) {
|
||||||
String text = firstContent.getStr("text");
|
String text = firstContent.getStr("text");
|
||||||
if (StringUtils.isNotBlank(text)) {
|
if (StringUtils.isNotBlank(text)) {
|
||||||
return JSONUtil.parseObj(text);
|
String trimmedText = text.trim();
|
||||||
|
if (trimmedText.startsWith("{") || trimmedText.startsWith("[")) {
|
||||||
|
try {
|
||||||
|
return JSONUtil.parseObj(trimmedText);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return trimmedText;
|
||||||
|
}
|
||||||
|
} else if ("true".equals(trimmedText)) {
|
||||||
|
return true;
|
||||||
|
} else if ("false".equals(trimmedText)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return trimmedText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue