Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android json解析JSONEXCEPTION_Android_Json - Fatal编程技术网

Android json解析JSONEXCEPTION

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

我从服务器获得了responseString,但当我放入JSONObject时,出现了一个错误:JSONException

下面是我的Json字符串(我从服务器上得到的内容!)

下面是我的android客户端代码

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