So I have a Json file that I have parsed, and I want to know how I can get the information in the Json file to the screen? Heres the parsing of the Json.
public String loadJSONFromAsset()
{
String json = null;
try
{
InputStream is = getAssets().open("JSON.json");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
json = new String(buffer, "UTF-8");
}
catch(IOException ex)
{
ex.printStackTrace();
return null;
}
return json;
}
JSON:
{"answers":[
{
"answer": "1"
},
{
"answer": "2"
},
{
"answer": "3"
},
{
"answer": "4"
},
{
"answer": "5"
}
]}
How do I get for example "4" into a variable? I hope my question is clear enough, if not, comment. What I want to do is simply output one of the numbers.