Ich versuche, den Titel von Liedern von soundcloud Likern der Benutzer zu erhalten, aber wenn ich die Textdatei zu einem JSONArray übertrage (erlaubt mir nicht, zu JSONObject zu übertragen) Ich finde keine Möglichkeit, die einzelnen Elemente, in diesem Fall "Titel", zu bekommen.Wie man json benutzt, um einzelne Elemente eines JSONArray zu erhalten
try {
Object obj = parser.parse(new FileReader(
"/switched this out but do have correct path"));
JSONArray jsonArray = (JSONArray) obj;
System.out.println(jsonArray.size());
System.out.println(jsonArray.iterator());
System.out.println(jsonArray.get(10));
Iterator<JSONObject> iterator = jsonArray.iterator();
while (iterator.hasNext()) {
System.out.println(iterator.next());
}
} catch (IOException | ParseException e) {
System.out.println("Something went wrong");
}
Hier ist die Ausgabe von jsonArray.get (10), wie Sie beteiligt sehen können, gibt es Tonnen von Elementen.
{"comment_count":40,"downloadable":false,"release":null,"created_at":"2016\/03\/31 04:41:13 +0000","description":"Other channels you might like...\r\n▶ @XXX\r\n▶ @YourSecret\r\n▶ @Future\r\n\r\nFree Download: http:\/\/dl.aia.ag\/no-will-hudgrove\r\nSpotify: http:\/\/spotify.aia.ag\/1MCU37t\r\niTunes: http:\/\/buy.aia.ag\/1pMeuob\r\n--------------------------------------------------------------------------------\r\nFollow @no-will\r\nhttp:\/\/twitter.com\/noahwilliamson\r\n\r\n♫ Listen on Spotify:\r\nhttp:\/\/aia.ag\/AIA-Spotify\r\n\r\n♫ Support AIA:\r\nhttp:\/\/aia.ag\/AIA-SC\r\nhttp:\/\/aia.ag\/AIA-FB\r\nhttp:\/\/aia.ag\/AIA-YT\r\nhttp:\/\/aia.ag\/AIA-IG\r\nhttp:\/\/aia.ag\/AIA-TW\r\n--------------------------------------------------------------------------------\r\nSubmit music to the email found in the sidebar of the channel info!","original_content_size":10463196,"title":"No Will - Hudgrove","track_type":"original","duration":242909,"video_url":null,"original_format":"mp3","artwork_url":"https:\/\/i1.sndcdn.com\/artworks-000155542480-tbt08v-large.jpg","streamable":true,"tag_list":"Chillwave Chillout Ambient Melodic Instrumental Beats Daydream Sexy \"Free Download\"","release_month":null,"genre":"Chill","release_day":null,"id":256391781,"state":"finished","last_modified":"2016\/04\/28 10:55:20 +0000","label_name":null,"commentable":true,"bpm":null,"favoritings_count":1981,"kind":"track","purchase_url":"http:\/\/dl.aia.ag\/no-will-hudgrove","release_year":null,"key_signature":null,"isrc":null,"sharing":"public","uri":"https:\/\/api.soundcloud.com\/tracks\/256391781","attachments_uri":"https:\/\/api.soundcloud.com\/tracks\/256391781\/attachments","download_count":0,"license":"all-rights-reserved","purchase_title":"Free Download","user_id":74594593,"embeddable_by":"all","waveform_url":"https:\/\/w1.sndcdn.com\/ucn5ZQ0XdvuY_m.png","permalink":"no-will-hudgrove","permalink_url":"http:\/\/soundcloud.com\/chill\/no-will-hudgrove","user":{"avatar_url":"https:\/\/i1.sndcdn.com\/avatars-000199251203-cuua5s-large.jpg","kind":"user","id":74594593,"permalink":"chill","permalink_url":"http:\/\/soundcloud.com\/chill","last_modified":"2016\/05\/02 22:33:11 +0000","uri":"https:\/\/api.soundcloud.com\/users\/74594593","username":"chill"},"label_id":null,"stream_url":"https:\/\/api.soundcloud.com\/tracks\/256391781\/stream","playback_count":6739}
Ich möchte den "Titel" von Objekten wie dem bekommen ^^^ irgendwelche Gedanken?
p.s. Die Iteratorschleife gibt 39 der Bruttoobjekte aus, die ich eingefügt habe
Versuchen: 'System.out.printin;' – Titus