Hi there I have a small problem i can't figure out. Im writing a RPC service using ZendFramework and Apigility. The response must be a json array. Next comes all the content negotiation code.
'controllers' => array(
'NmdaWebApi\\V1\\Rpc\\Hola\\Controller' => 'Json',
'accept_whitelist' => array(
'NmdaWebApi\\V1\\Rpc\\Hola\\Controller' => array(
0 => 'application/vnd.nmda-web-api.v1+json',
1 => 'application/json',
2 => 'application/*+json',
),
'content_type_whitelist' => array(
'NmdaWebApi\\V1\\Rpc\\Hola\\Controller' => array(
0 => 'application/json',
),
This is how I have the controller
class HolaController extends AbstractActionController{
public function holaAction(){
return array(1,2,3,4,5);}}
And here is the returned json.
{"0":1,"1":2,"2":3,"3":4,"4":5}
I'm getting this list and a I want an array. Here is another example.
return array(1,2,3,4,array(5,6,7));
{"0":1,"1":2,"2":3,"3":4,"4":[5,6,7]}
Can someone explain me how to avoid this?
Edit_1
I figured out a workaround. Using HalJson fixes the problem. But i still cant understand why it doesnt work with normal Json.
'controllers' => array(
'NmdaWebApi\\V1\\Rpc\\Hola\\Controller' => 'HalJson',