How can I get the index names of a JSON object in Java in Android Studio.
Code:
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("nome", "");
jsonObject.put("sobrenome", "asdasd");
jsonObject.put("nomeCompleto", "Renato Vieira de Souza");
} catch (JSONException e) {
e.printStackTrace();
}
for(int i=0; i < jsonObject.length(); i++){
try {
if(VERIFICAR AQUI SE CADA INDICE DO ARRAY É MENOR QUE 1){
Recursos.toastLento(getApplicationContext(), "nome vazio");
}
} catch (JSONException e) {
e.printStackTrace();
}
}
My need is to detect any index that appears in json and check if it is empty, so I will create a method to validate a json and tell which json or which ones are empty.