我遇到了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"
}
正如您所看到的,有两个名为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
变量中的值。
任何帮助将不胜感激。
答案 0 :(得分:1)
这一行似乎有错误:
"listOfBusinessdays":"1","2","5","6","7"],
一个封闭的方括号,但之前没有开放式支架。 可能是挂断解析器。