0

我陷入了一种情况,我的JSONStringruleFormJSONString)看起来像:

{
"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 个属性被命名fromTimetoTime其中有一个:

所以在用 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变量中的值。

任何帮助将不胜感激。

4

1 回答 1

1

这一行似乎有错误:

"listOfBusinessdays":"1","2","5","6","7"],

一个封闭的方括号,但之前没有开放的括号。可能是这挂断了解析器。

于 2012-12-22T09:23:45.387 回答