使用FOSRestBundle以数组形式发送和接收数据到API

问题描述:

您好我使用FOSRestBundle来创建我的API。 我必须发送像ARRAY数据:使用FOSRestBundle以数组形式发送和接收数据到API

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

以及更多。

我阅读文档,我不知道如何recive数据数组!

我的功能:

/** 
    * @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'); 

我尝试recive参数发送者是()数组 怎么会呢?

我用symfony的2.8

请通过document正常。我想,您需要正确配置View layerListener support以通过[json,xml]与客户端进行交互。开始使用json。然后,您可以将数组作为JSON字符串传递,该字符串也可以由客户端解码为数组。

我曾经通过Request从客户端获取请求数据(GET,POST)。它又被format_listener转换为数组/对象。

希望这会有所帮助!