空数据解析数据JSON

时间:2013-03-30 02:52:05

标签: ios json nsjsonserialization

当我在浏览器上查看此内容(方法结束)时,我看到了JSON回显的打印输出。

JSON echo

[{"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

有什么想法?感谢

0 个答案:

没有答案