【问题标题】:JsonArray to JsonObjectJsonArray 到 JsonObject
【发布时间】:2017-10-11 13:18:43
【问题描述】:

我不知道我在这里做错了什么:

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

我收到此错误:JSONArray[0] 不是 JSONObject。

有谁知道我做错了什么?

worklogIssue = 数组列表。

谢谢

【问题讨论】:

  • 您的 JSON 输入在哪里?该问题也应标记为Java

标签: arrays json


【解决方案1】:

String 不是JSONObject。你可以像这样得到id

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-28
    • 2018-07-18
    相关资源
    最近更新 更多