0

当我在浏览器上查看这个(方法的结尾)时,我看到了 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 时,数据为空(但我看到了字节,但数组显示为 0x0000

NSArray* data=[NSJSONSerialization JSONObjectWithData:webData options:0 error:&error];
    NSLog(@"name = %@",[data objectAtIndex:0]);//Null

有什么想法吗?谢谢

4

0 回答 0