So here is the basis for building my JSON response back to my JS.
$this->_response['vendor'] = array();
foreach ($_results as $_row) {
$this->_response['vendor'][$_row['id']] = $_row;
}
echo(json_encode($this->_response));
This is fine and builds objects in javascript fine, unless there were no results. In that case, the php sees it as an empty numeric array, instead of an associative array. This then comes down to javascript and converts to an empty array instead of an empty object.
I know I can fix this in a number of ways by checking things, pre-declaring the variables as objects in javascript etc. What I'm wondering is if there is a way to declare an empty associative array in php, or some other way to force json_encode to create an object ("{}") instead.