I have JSON returned from my web server in the following form:
{"success":false,"errors":{"username":["Invalid username","Username too short"],"password":["Invalid password"]}}
How can I, in Java, parse the JSON to get the first key and the first value of that key? So in the above case, the output should be:
username
Invalid username
My current code looks like this:
String json =  new String(((TypedByteArray) retrofitError.getResponse().getBody()).getBytes());
try {
    JSONObject obj = new JSONObject(json);
    String success = obj.getString("success");
    JSONObject errors = obj.getJSONObject("errors");
    // TODO
} catch (JSONException e) {
    e.printStackTrace();
}
 
    