I'm try to convert my JSON file to java but error numberFormatException : null
Can someone help me find out the what the problems?
11:33:17,331 SEVERE [com.vaadin.server.DefaultErrorHandler] (default task-21) : java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:542)
at java.lang.Integer.parseInt(Integer.java:615)
at my.gov.moh.hiskkm.gson.main.JsonUtil.layoutColumn(JsonUtil.java:171)
at my.gov.moh.hiskkm.patients.gson.ViewPanelView.mainJsonProcess(ViewPanelView.java:492)
at my.gov.moh.hiskkm.patients.gson.ViewPanelView.<init>(ViewPanelView.java:153)
at my.gov.moh.hiskkm.patients.component.PatientNewNote$1.valueChange(PatientNewNote.java:286)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Here my JSON
public static Integer layoutColumn(String json, String section) throws
JSONException {
jsonObj = new JSONObject(json);
Object o1 = jsonObj.getJSONObject(section);
Gson o2 = new GsonBuilder().create();
String s1 = o1.toString();
System.out.println("Check S1" + s1);
SectionNode sn = o2.fromJson(s1, SectionNode.class);
return Integer.parseInt(sn.getLayout());
}
Integer.parseInt(sn.getLayout())
The above line will throw Number Format Exception when the argument to parseInt
method is not a valid String
representation of Integer
.
Make sure sn.getLayout is a valid String representation of an Integer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.