これ (メソッドの最後) をブラウザーで表示すると、JSON エコーの出力が表示されます。
JSON エコー
[{"0":"2222","id":"2222","1":"john","first":"john","2":"true","last":"true"},{"0":"35","id":"35","1":"Griffin","first":"Griffin","2":"Peter","last":"Peter"},{"0":"40","id":"40","1":"cameron","first":"cameron","2":"Peter","last":"Peter"},{"0":"22","id":"22","1":"Sqgger","first":"Sqgger","2":"Peter","last":"Peter"},{"0":"900","id":"900","1":"sayo","first":"sayo","2":"nara","last":"nara"},{"0":"9000","id":"9000","1":"sayaaao","first":"sayaaao","2":"nara","last":"nara"},{"0":"9001","id":"9001","1":"sayaaao","first":"sayaaao","2":"nara","last":"nara"}]
//Perform query
$result = mysqli_query($con,"SELECT * FROM User");
$myJson=array();
//Parse to array
while($row = mysqli_fetch_array($result)){
$myJson[]=$row;
//echo $row['first'] . " " . $row['last'];
//echo "<br />";
}
//Close connection
mysqli_close($con);
//Encode and send response
echo json_encode($myJson);
しかし、私の iOS アプリでは、データを NSLog に入れると null になります (ただし、バイトは表示されますが、配列は 0x0000 と表示されます)
NSArray* data=[NSJSONSerialization JSONObjectWithData:webData options:0 error:&error];
NSLog(@"name = %@",[data objectAtIndex:0]);//Null
何かご意見は?ありがとう