How to parse a Json with 2 columns in Objective-C?

0

In a Get using PHP I'm making the request of 2 columns this way:

<?php
include 'conexao.php';
header('Content-Type: text/html; charset=UTF-8');
//Converte para UTF8 os resultados da query
mysql_set_charset('UTF8');
//Retorna resultado query idRegistro e updateatRegistro
$sql = "SELECT idRegistro,updateatRegistro FROM jump";
$resultado = mysql_query($sql) or die ("Erro: ".mysql_error());
// Crinha variável linha do tipo array
$linha = array();
  while($r = mysql_fetch_assoc($resultado))
    {  
        $linha [] = $r;
    }
 echo json_encode($linha);
mysql_close(); 
?>

And I'm trying to get the values. But I noticed that in responseData, I'm getting a response with 2 layers of arrays and 1 dictionary:

this way:

1º Array |2º Array| Dicionario 
    [0] =    [0]    = idRegistro: 1;
             [1]    = updateAt: 2015/02/18 19:55:42;

When I try to extract the data from the first layer of the array, the return should be another array, but it is being recognized as a dictionary. I think it's due to Json's coding.

I believe I should query these columns in some other way. Could anyone suggest a better way?

    
asked by anonymous 19.02.2015 / 02:53

1 answer

1

After some tests, I noticed that Xcode recognizes the second array as a dictionary, so I sent the message ...valueForKey:@"idRegitro"]; and it returned the value correctly.

But I was appalled, as it seems to be a type recognition error, probably generated by the encode / decode json format, generated on the server and received by the native Json API in Xcode.

    
20.02.2015 / 13:00