이 JSON을 읽었습니까? 아직 JSON을 사용하지 않아서 데이터를 가져올 수 없습니다.데이터 가져 오기 JSON Android 오류
public void handleResponse(String response) {
EditText edFirstName = (EditText) findViewById(R.id.testeNome);
EditText edLastName = (EditText) findViewById(R.id.testeEnder);
EditText edEmail = (EditText) findViewById(R.id.testeCpf);
edFirstName.setText("");
edLastName.setText("");
edEmail.setText("");
try {
//------------------------------//
//Array Json
JSONArray JArray = new JSONArray(response.toString());
JSONObject JObjeto = JArray.getJSONObject(0);
JSONObject posicao = JObjeto.getJSONObject(KEY_CLI);
String firstName = posicao.getString("id");
edFirstName.setText(firstName);
}
} catch (Exception e) {
Log.e(TAG, e.getLocalizedMessage(), e);
}
}
오류는 객체 배열을 변환 할 수 없습니다 말 : 여기
{
"cliente": [
{
"cpf": "82334673382",
"endereco": "ewkiewowieou",
"id": "11",
"nome": "Wagner Assis"
},
{
"cpf": "82334889929",
"endereco": "uuqwuwqu",
"id": "14",
"nome": "GS Advogados"
},
{
"cpf": "3237287383",
"endereco": "ewiueiwu",
"id": "15",
"nome": "Empreiteira GH"
},
{
"cpf": "73448723349",
"endereco": "dsgdsjhdjh",
"id": "17",
"nome": "Cobrança HH"
},
{
"cpf": "7337474847",
"endereco": "weuwuewiu",
"id": "18",
"nome": "Pollo GH"
},
{
"cpf": "23423423",
"endereco": "rewrwer",
"id": "19",
"nome": "Finanças LH"
},
{
"cpf": "847384378",
"endereco": "jsjsdhjsdh",
"id": "20",
"nome": "Empreisa SA"
},
{
"cpf": "123456",
"endereco": "ewewew",
"id": "21",
"nome": "João Pedro"
},
{
"cpf": "73447832828",
"endereco": "dsjdhsjh",
"id": "22",
"nome": "Pedro Otavio"
},
{
"cpf": "312312",
"endereco": "rwwree",
"id": "23",
"nome": "Carlos Philip"
}
]
}
내가 데이터를 가져 오는 방법입니다 : 여기
는 JSON이다. 누군가 나를 도울 수 있습니까?
'response' 문자열은 여러분이 우리에게 보여주고있는 것에서 객체를 보유하고 있습니다. 즉, 여러분이 우리에게 보여주고있는 객체를 포함하고 있습니다. 즉,'JSONArray'를 만들 수 없습니다. 'response'로부터 객체를 생성하고,'cliente' 키에 의해 색인 된 배열을 얻은 다음이리스트의 각 엔트리를 처리해야합니다. – bvidal
그래서 json 객체와 배열을 처리해야합니까? 나에게 모범을 보일까? 나는 json을 처음 접했을 뿐이고 숫자가 아닌 고객과 만 처리 할 수 있습니다. – zullyB
다음은 좋은 시작이 될만한 답변을 찾으십시오 – bvidal