I would like to know 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 even 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 code in java:
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)
{
}