1
I wonder how I read json in two different ways.
1 - I have a Json
{"nome": "JOA", "cpf": 7.4417, "idade": "15"},{"nome": "PAT", "cpf": 8.5528, "idade": "20"}"};
This one I can read and play in variables, but only the first part, I would like to know how to get the value of the second part of json.
Follow the java code:
JSONObject obj;
String nome = "", cpf = "", idade = "";
String teste = "{\"nome\": \"JOA\", \"cpf\": 7.4417, \"idade\": \"15\"},{\"nome\": \"PAT\", \"cpf\": 8.5528, \"idade\": \"20\"}";
try {
obj = new JSONObject(teste);
nome = obj.getString("nome");
cpf = obj.getString("cpf");
idade = obj.getString("idade");
//Toast.makeText(getApplicationContext(), nome, Toast.LENGTH_LONG).show();
}
catch (JSONException ex)
{
}
Here’s my +1; =D
– viana
Perfect, I understand now the concept of Arrey and Objects within Json.
– Patrick Camargo
@Did Patrickcamargo solve your problem? If yes, please mark the answer as correct, if you do not know how to do it read: https://pt.meta.stackoverflow.com/q/1078/3635
– Guilherme Nascimento