I'm calling json_encode to sendo a objects array back to the user, and at other parts of my code it works properly, but at this one it return a empty structure string.
Here is the result when I call json_encode on the array before encoding:
array(3) {
[0]=>
object(MinaProxy)#5 (7) {
["carregado":"MinaProxy":private]=>
bool(true)
["link":"MinaProxy":private]=>
int(1)
["idMina":protected]=>
int(1)
["qntOuro":protected]=>
int(2000)
["x":protected]=>
int(307)
["idPartida":protected]=>
int(1)
["proximo":protected]=>
int(1)
}
[1]=>
object(MinaProxy)#6 (7) {
["carregado":"MinaProxy":private]=>
bool(true)
["link":"MinaProxy":private]=>
int(2)
["idMina":protected]=>
int(2)
["qntOuro":protected]=>
int(2000)
["x":protected]=>
int(512)
["idPartida":protected]=>
int(1)
["proximo":protected]=>
int(2)
}
[2]=>
object(MinaProxy)#7 (7) {
["carregado":"MinaProxy":private]=>
bool(true)
["link":"MinaProxy":private]=>
int(3)
["idMina":protected]=>
int(3)
["qntOuro":protected]=>
int(2000)
["x":protected]=>
int(716)
["idPartida":protected]=>
int(1)
["proximo":protected]=>
NULL
}
}
Here is the result after json_encode:
[{},{},{}]
As can be noticed, there is no special characters in the original array, so I do not think it is a encoding issue. Here is the code where I call json_encode:
elseif($dados['acao'] == 'recuperarMinas') {
$i = 0;
$array = array();
while ($this->partida->minas->temProximo()) {
$array[$i] = $this->partida->minas->getProximoAvancando();
$array[$i]->getIdPartida();
$i++;
}
$_SESSION['partida'] = $this->partida;
$retornoJson = json_encode($array);
return $retornoJson;
}