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

前端 未结 3 548
再見小時候
再見小時候 2020-12-30 04:35

I am trying to read a JSON file like this:

{
  \"presentationName\" : \"Here some text\",
  \"presentationAutor\" : \"Here some text\",
  \"presentationSlide         


        
3条回答
  •  滥情空心
    2020-12-30 05:18

    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);
            }
    

提交回复
热议问题