我陷入了一种情况,我的JSONString
(ruleFormJSONString)看起来像:
{
"ruleDescription":"Test Rule2 Description",
"urlId":"1",
"listOfBusinessdays":["1","2","5","6","7"],
"status":"1",
"hierarchyId":"3",
"fromTime":"08:00",
"toTime":"18:00",
"dcnid":"1",
"eventId":"1",
"rowstate":"1",
"listOfLocations":["ASM","DEL"],
"ruleName":"Test Rule2",
"ruleId":"7","msgId":"1"
}
如您所见,有 2 个属性被命名fromTime
,toTime
其中有一个:
所以在用 Java 解析这个时,我使用了
JSONObject ruleFormJSON = JSONObject.fromString(ruleFormJSONString);
String fromTime = (String)ruleFormJSON.getString("fromTime");
String toTime = (String)ruleFormJSON.getString("toTime");
我得到了NumberFormatException
一个
java.lang.NumberFormatException:对于输入字符串:“18:00”
所以请建议我如何获取相应String
变量中的值。
任何帮助将不胜感激。