gpt4 book ai didi

java - "A JSONArray text must start with ' [' at character 1 of null"

转载 作者:行者123 更新时间:2023-12-01 17:39:07 31 4
gpt4 key购买 nike

只是想知道这个错误可能意味着什么?我从下面的代码中得到它..

 try{
JSONArray jArray = new JSONArray(result);
for(int i=0;i<jArray.length();i++){
JSONObject json_data = jArray.getJSONObject(i);
Log.i("log_tag","id: "+json_data.getInt("id")+
", name: "+json_data.getString("name")+
", sex: "+json_data.getInt("sex")+
", birthyear: "+json_data.getInt("birthyear")
);
}
}
}catch(JSONException e){
Log.e("log_tag", "Error parsing data "+e.toString());
}

最佳答案

结果显然是空的。或者它根本不以 [ 开头。在调用 JSONArray 之前打印出来看看。

另请查看JSONArray source 。它需要 JavaScript 数组语法,例如:

['这个', '是', '数组', '语法']

关于java - "A JSONArray text must start with ' [' at character 1 of null",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3085830/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com