How do I parse a JSONArray in Java with Json.simple?

You never assign a new value to jsonObject, so inside the loop it still refers to the full data object. I think you want something like:

JSONObject slide = i.next();
String title = (String)slide.get("title");

It's working! Thx Russell. I will finish my exercice and try GSON to see the difference.

New code here:

        JSONArray slideContent = (JSONArray) jsonObject.get("presentationSlides");
        Iterator i = slideContent.iterator();

        while (i.hasNext()) {
            JSONObject slide = (JSONObject) i.next();
            String title = (String)slide.get("title");
            System.out.println(title);
        }

Tags:

Java

Arrays

Json