mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-29 18:23:59 +08:00
update:增加mcp调用后数据类型的判断
This commit is contained in:
+14
-1
@@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user