i have some problems with my code with the plugin codename one it tell me that there's a nullpointer exception but the same code work in some other computers so i don't really know where come the problem exact
Form hi = new Form("Hi World");
SpanLabel sp = new SpanLabel();
hi.add(sp);
hi.show();
ConnectionRequest con = new ConnectionRequest();
con.setUrl("http://localhost/pidev2017/select.php");
con.addResponseListener(new ActionListener<NetworkEvent>() {
@Override
public void actionPerformed(NetworkEvent evt) {
System.out.println(getListEtudiant(new String(con.getResponseData())));
sp.setText(getListEtudiant(new String(con.getResponseData())) + "");
hi.refreshTheme();
}
});
NetworkManager.getInstance().addToQueue(con);
}
public ArrayList<Etudiant> getListEtudiant(String json) {
ArrayList<Etudiant> listEtudiants = new ArrayList<>();
try {
JSONParser j = new JSONParser();
Map<String, Object> etudiants = j.parseJSON(new CharArrayReader(json.toCharArray()));
System.out.println();
List<Map<String, Object>> list = (List<Map<String, Object>>) etudiants.get("etudiant");
for (Map<String, Object> obj : list) {
Etudiant e = new Etudiant();
e.setAge(Integer.parseInt(obj.get("age").toString()));
e.setCin(obj.get("cin").toString());
e.setNom(obj.get("nom").toString());
listEtudiants.add(e);
}
} catch (IOException ex) {
}
return listEtudiants;
}
this is the error i get
java.lang.NullPointerException [EDT] 0:0:0,2 - Expected null for key value while parsing JSON token at row: 2 column: 72 buffer: e1elxde-exe-dlde1ell [EDT] 0:0:0,2 - Expected null for key value while parsing JSON token at row: 2 column: 85 buffer: e1elxde-exe-dlde1ell0elldd [EDT] 0:0:0,2 - Expected true for key value while parsing JSON token at row: 3 column: 2 buffer: e1elxde-exe-dlde1ell0elldd1 [EDT] 0:0:0,2 - Expected true for key value while parsing JSON token at row: 3 column: 3 buffer: e1elxde-exe-dlde1ell0elldd1 [EDT] 0:0:0,2 - Expected null for key value while parsing JSON token at row: 3 column: 7 buffer: e1elxde-exe-dlde1ell0elldd1l [EDT] 0:0:0,2 - Expected true for key value while parsing JSON token at row: 3 column: 10 buffer: e1elxde-exe-dlde1ell0elldd1lef [EDT] 0:0:0,2 - Expected null for key value while parsing JSON token at row: 3 column: 34 buffer: e1elxde-exe-dlde1ell0elldd1leflf57900l
at com.mycompany.myapp.MyApplication.getListEtudiant(MyApplication.java:80)
at com.mycompany.myapp.MyApplication$1.actionPerformed(MyApplication.java:59)
at com.mycompany.myapp.MyApplication$1.actionPerformed(MyApplication.java:55)
at com.codename1.ui.util.EventDispatcher.fireActionSync(EventDispatcher.java:459)
at com.codename1.ui.util.EventDispatcher.access$100(EventDispatcher.java:45)
at com.codename1.ui.util.EventDispatcher$CallbackClass.run(EventDispatcher.java:95)
at com.codename1.ui.Display.processSerialCalls(Display.java:1152)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1096)
at com.codename1.ui.Display.mainEDTLoop(Display.java:997)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)