Also habe ich eine JSON-Datei, die ich analysiert habe, und ich möchte wissen, wie ich die Informationen in der JSON-Datei auf den Bildschirm bekommen kann? Heres das Parsing der Json.Ausgabe geparsten JSON-Daten
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"
}
]}
Wie ich zum Beispiel bekommt "4" in eine Variable? Ich hoffe meine Frage ist klar genug, wenn nicht, Kommentar. Ich möchte einfach eine der Zahlen ausgeben.
Check diese http lösen: // stackoverflow.com/questions/2591098/how-to-parse-json-in-java?rq=1 –