如何从以下JSON对象中检索ids数组。
{"bets":[{"bet":[{"gid":"10","Result":null}]},{"bet":[{"gid":"7","Result":null}]},{"bet":[{"gid":"3","Result":null},{"gid":"6","Result":"2"}]},{"bet":[{"gid":"6","Result":"2"},{"gid":"4","Result":"1"}]},{"bet":[{"gid":"6","Result":"2"},{"gid":"4","Result":"1"}]}]}{"ids":["9c9nogs6of","ank4kt3gqo","jfgrt91nk4","a8qmoq7v4q","8mov5ita1t"]}
我试过
allids = jObj.getJSONArray("ids");
哪个应该有效,因为它适用于jObj.getJSONArray("bets");
但是我在logcat E/Buffer Error﹕ Error converting result org.json.JSONException: No value for ids
PHP文件
<?php
// get tag
$param= $_POST['param'];
$bet = explode("//",$param);
$allbetslength = count($bet);
$ultresponse["bets"] = array();
$idresponse["ids"] = array();
for ($x = 0; $x < $allbetslength; $x++) {
$indid = substr($bet[$x],0,10);
array_push($idresponse["ids"], $indid);
$bet[$x] = substr($bet[$x],10);
$id = explode(",",$bet[$x]);
$arrlength = count($id);
// include db handler
require_once 'include/Check_Bets.php';
$db = new Check_Bets();
$response["bet"] = array();
for($y = 0; $y < $arrlength; $y++) {
$result= $db->checkuserbets($id[$y]);
array_push($response["bet"], $result);
}
array_push($ultresponse["bets"], $response);
array_push($ultresponse["bets"], $idresponse["ids"]);
}
echo json_encode($ultresponse);
?>