Bonjour,

Je récupère des données de ma BDD depuis mon application android grace a une API de type REST en json. Le champ login_id est un int a null dans ma base et lorsque que je veux récupérer ce derniers avec :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
try
		{
			JSONArray jArray = new JSONArray(result);
			for(int i=0;i<jArray.length();i++){
				JSONObject json_data = jArray.getJSONObject(i);
				// Résultats de la requête : json_data.getInt("ID_ville")
				//returnString += jArray.getJSONObject(i)+"\n";
				name = json_data.getString("name");
				surname = json_data.getString("surname");
				numtel = json_data.getString("numtel");
				login_id = json_data.getInt("login_id");
			}
		}
J'obtiens : "Error parsing data:org.json.JSONException: Value null at login_id of type org.json.JSONObject$1 cannot be converted to int"

Normalement faire :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
login_id = (Integer)json_data.getInt("login_id");
devrait résoudre le problème, mais non...