I have a project where I search the database via JSON, to export this data in Excel format. I am adding a new search, but I have a string array, but I can not get the data from the database so that it returns only the first data of that array.
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject js = jsonArray.getJSONObject(i);
JSONObject js2 = js.getJSONObject("cliente").optJSONObject("enderecoList").getJSONObject("municipio");
JSONObject jsUnidade = js.getJSONObject("unidade");
JSONObject jsUnidadePai = jsUnidade.getJSONObject("unidadePai");
JSONObject jsCliente = js.getJSONObject("cliente");
JSONObject jsApl = js.getJSONObject("apl");
JSONObject jsSetor = js.getJSONObject("setor");
I'd like it to return only the first data I found in the array getJSONObject("municipio")
It is not written getJSONArray("municipio")
, because I can not give a getString to show the returned value.
I'm a beginner in java and JSON.