mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-25 16:43:55 +08:00
fix:number熟知去掉小数点后的00
This commit is contained in:
+7
-1
@@ -171,7 +171,13 @@ public class ConfigServiceImpl implements ConfigService {
|
|||||||
switch (param.getValueType().toLowerCase()) {
|
switch (param.getValueType().toLowerCase()) {
|
||||||
case "number":
|
case "number":
|
||||||
try {
|
try {
|
||||||
current.put(lastKey, Double.parseDouble(value));
|
double doubleValue = Double.parseDouble(value);
|
||||||
|
// 如果数值是整数形式,则转换为Integer
|
||||||
|
if (doubleValue == (int) doubleValue) {
|
||||||
|
current.put(lastKey, (int) doubleValue);
|
||||||
|
} else {
|
||||||
|
current.put(lastKey, doubleValue);
|
||||||
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
current.put(lastKey, value);
|
current.put(lastKey, value);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user