-1

Hi I use FOSRestBundle to create my API. I have to send data as ARRAY like:

"sender"=>array("name"=>"adm","city"=>"Rz") 

and more.

I read documentation and I didn't know how to recive data array!

My function:

/**
     * @QueryParam(name="recipient", description="Page of the overview.")
     * @QueryParam(name="sender", description="Page of the overview.")
     *

     */
    public function putDispatchAction(ParamFetcher $params)
    {

//       $params =  $request;
        $rec = $params->get('recipient');
        $sender = $params->get('sender');

I try to recive parameter sender which is array() But how?

I use symfony 2.8

marczak
  • 489
  • 2
  • 8
  • 17

1 Answers1

1

Please go through the document properly. I guess, you need to configure View layer and Listener support properly to interact with client via [json, xml]. TO start with use json. Then, you can pass the array as an JSON string which again can be decoded to array by client.

I used to get request data (GET, POST) from client via Request. It was again being transformed by format_listener to array / object.

Hope this helps!

Jeet
  • 1,587
  • 1
  • 9
  • 22