2017-10-11 3 views
0

ich weiß nicht, was ich hier falsch mache:JsonArray zu JsonObject

public void createArchive(ArrayList<String> worklogIssue) throws IOException { 
    String id = null; 
     int i = 0; 

     JSONArray json = new JSONArray(worklogIssue); 


     for (i = 0; i < worklogIssue.size(); i++){ 
      JSONObject json_obj = json.getJSONObject(i); 
      id = json_obj.getString("id"); 
     } 
    } 

ich bin diesen Fehler: JSONArray [0] ist kein JSONObject.

Weiß jemand, was ich falsch mache?

worklogIssue = Arraylist.

Dank

+0

Wo ist Ihr JSON-Eingang? Die Frage sollte auch mit Java markiert werden. –

+0

@MuriloMoronMarques Ist das gelöst? – aaron

Antwort

0

A String ist kein JSONObject. Sie können id wie folgt erhalten:

public void createArchive(ArrayList<String> worklogIssue) throws IOException 
{ 
    String id = null; 
    int i = 0; 
    for (i = 0; i < worklogIssue.size(); i++) { 
     id = worklogIssue.get(i); 
    } 
}