我在Java类中打印scala Map的值,如下所示
Option<Object> data = JSON.parseFull((String)zkClient.readData(statePath));
scala.collection.immutable.Map<String, Object> leaderInfo = scala.collection.immutable.Map<String, Object>) data.get();
System.out.println(leaderInfo.toString();
但我很惊讶有时值是浮点数
controller_epoch -> 6.0, leader -> 1.0, version -> 1.0, leader_epoch -> 4.0, isr -> List(1.0)
有时候是整数。
controller_epoch -> 6, leader -> 1, version -> 1, leader_epoch -> 4, isr -> List(1)
我希望数据始终被解析为Integer。有没有办法做到这一点?