Looks to me like a possible issue in Zend\View\Variables (ArrayObject doesn't
seem to act like a regular array with the ArrayObject::STD_PROP_LIST flag
set.. may need further investigation).
Try changing line 60 in Zend/View/Variables.php
from:
ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS,
to
ArrayObject::ARRAY_AS_PROPS,
As for the "content" key appearing in your result, that's because you
probably have a layout enabled (which would be a parent view model to the
one you're returning in the controller)
In order to return just the name/key pairs from your action, you can grab
the parent view model from the MvcEvent:
...
class IndexController extends ActionController
{
public function indexAction()
{
$e = $this->getEvent();
$viewModel = $e->getViewModel();
$viewModel->setVariables(array(
'name1' => 'value1',
'name2' => 'value2'
));
}
}
...
But keep in mind if you do it this way, the 'content' key probably won't be
there if your layout goes looking for it.
-Matt P.
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/ZF2-contextSwitch-to-json-tp4418147p4452594.html
Sent from the Zend Framework mailing list archive at Nabble.com.
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]