0

jsonObject に問題があります。

私が持っているアンドロイドアプリで:

try {
        jObj = new JSONObject(json);
    } catch (JSONException e) {
        Log.e("JSON Parser", "Error parsing data " + e.toString());
        Log.e("JSON Parser2", "json: "+json);
    }

ログキャットは次のとおりです。

01-03 16:50:09.239: E/JSON Parser(17447): Error parsing data org.json.JSONException: Value [] of type org.json.JSONArray cannot be converted to JSONObject 
01-03 16:50:09.239: E/JSON Parser2(17447): json: [][][]{"code":0,"message":"Segnalazione inviata correttamente"}

PHPで私は持っています:

$response = array();
$response["code"] = $e['code'];
$response["message"] = $e['message'];
echo json_encode($response);

ありがとう

4

3 に答える 3

0

問題はphpコードにあると思います。以下のようにphpコードを変更してみてください

$response = array("code" => $e['code'], "message" =>$e['message']);
echo json_encode($response);
于 2013-01-03T16:23:39.140 に答える
0

最上位オブジェクトが配列の場合は、JSONArrayを使用します。

   try {
        jArr = new JSONArray(json);
    } catch (JSONException e) {
        Log.e("JSON Parser", "Error parsing data " + e.toString());
        Log.e("JSON Parser2", "json: "+json);
    }
于 2013-01-03T16:00:58.003 に答える