0
爲int
private def getInterfaceInfo(rawData: JsValue): NetworkDeviceInterfaceInfo = {
def getTotalInterfaces(group1: JsValue): Int = {
var count: Int = 0
val interfacesList = group1.as[JsObject].fields.groupBy {
case (key, value) => key.split("_", 2)(1)
}.map {
case (key, values) =>
(key, values.toMap)
}.map {
case (key, valuesMap) =>
val ifType = valuesMap.get(s"ifType_$key").getOrElse()
if (ifType.toString.contains("6")) {
count += 1
}
}
return count
}
//這裏的代碼VAL的ifType我得到了它的價值「2」,我希望它像2 ......任何人可以幫助我從這裏走出如何轉換值從地圖得到了在斯卡拉
你試過.toInt嗎?但是你必須把這個.toInt包裝在Try塊中! – 2014-09-23 06:05:39