Grabbing an JSON array from a query. It’s not printing the keyss with in the data.
What I expect:
["0":"3675E5010E2738","1":"4114009","2":"2012-11-05","3":"Active","4":"2012-12-11"]
What I get…
["3675E5010E2738","4114009","2012-11-05","Active","2012-12-11"]
JSON is produced from PHP/JSON encode:
$array = $model->ListData();
echo json_encode($array);
I’ve tried loading both loadRowList(); and loadAssocList(); and neither produce the keys.
Because that’s not how JSON represents arrays
["0":"3675E5010E2738","1":"4114009","2":"2012-11-05","3":"Active","4":"2012-12-11"]is not valid JSON.{"0":"3675E5010E2738","1":"4114009","2":"2012-11-05","3":"Active","4":"2012-12-11"}is, but that’s the representation of an object, not an array.If
$model->ListData();returns an array, as your code suggests that it does, then the representation that you’re getting is correct.Anyway, since
json[0]would work the same way, regardless of whether it was an array or an object with numerical keys, what does it matter?