Android json解析JSONEXCEPTION
我从服务器获得了responseString,但当我放入JSONObject时,出现了一个错误:JSONException 下面是我的Json字符串(我从服务器上得到的内容!) 下面是我的android客户端代码Android json解析JSONEXCEPTION,android,json,Android,Json,我从服务器获得了responseString,但当我放入JSONObject时,出现了一个错误:JSONException 下面是我的Json字符串(我从服务器上得到的内容!) 下面是我的android客户端代码 JSONObject jsonObject = new JSONObject(json); tmp_myregID = jsonObject.getString("myregID"); Log.v("3333","1111"); tmp_your
JSONObject jsonObject = new JSONObject(json);
tmp_myregID = jsonObject.getString("myregID");
Log.v("3333","1111");
tmp_yourregID = jsonObject.getString("yourregID");
代码流停止在
JSONObject JSONObject=new JSONObject(json)
您的json根元素是JsonArray而不是json对象,所以先获取JsonArray。您的json根元素是JsonArray而不是json对象,所以先获取JsonArray。您的json根元素是JsonArray而不是json对象,因此,首先获取JsonArray。您的Json根元素是JsonArray而不是Json对象,因此首先获取JsonArray。您首先需要获取数组[…]
,然后获取对象{…}
:
try {
JSONArray jsonArray = new JSONArray(jsonString);
JSONObject jsonObject = jsonArray.getJSONObject(0);
Log.e(TAG, jsonObject.getString("myregID"));
Log.e(TAG, jsonObject.getString("yourregID"));
} catch (JSONException e) {
e.printStackTrace();
}
首先需要获取数组
[…]
,然后获取对象{…}
:
try {
JSONArray jsonArray = new JSONArray(jsonString);
JSONObject jsonObject = jsonArray.getJSONObject(0);
Log.e(TAG, jsonObject.getString("myregID"));
Log.e(TAG, jsonObject.getString("yourregID"));
} catch (JSONException e) {
e.printStackTrace();
}
首先需要获取数组
[…]
,然后获取对象{…}
:
try {
JSONArray jsonArray = new JSONArray(jsonString);
JSONObject jsonObject = jsonArray.getJSONObject(0);
Log.e(TAG, jsonObject.getString("myregID"));
Log.e(TAG, jsonObject.getString("yourregID"));
} catch (JSONException e) {
e.printStackTrace();
}
首先需要获取数组
[…]
,然后获取对象{…}
:
try {
JSONArray jsonArray = new JSONArray(jsonString);
JSONObject jsonObject = jsonArray.getJSONObject(0);
Log.e(TAG, jsonObject.getString("myregID"));
Log.e(TAG, jsonObject.getString("yourregID"));
} catch (JSONException e) {
e.printStackTrace();
}