I have the following JSON:
{"errors":[{"code":888,"errorId":"xxx","message":"String value expected","fields":["name", "address"]}, {}, {}]}
I want to be able to get "fields" the following way:
public static String getField(json, errorsIndex, fieldIndex) {
JSONObject errorJson = json.getJSONArray("errors").getJSONObject(errorIndex);
String value = errorJson.[getTheListOfMyFields].get(fieldIndex);
return value;
}
But I can't find a way to make this part [getTheListOfMyFields]. Any suggestion?
getTheListOfMyFieldssupposed to be an index?valueto be the element in the "fields" array at indexfieldIndex, is that correct? So for example, iffieldIndexwere 1, thenvaluewould be "address"?