mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-26 04:39:53 +01:00
fix:number熟知去掉小数点后的00
This commit is contained in:
parent
03d89d22ec
commit
25da9fe119
1 changed files with 7 additions and 1 deletions
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue