首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >忽略JMSSerializerBundle AccessorOrder自定义

忽略JMSSerializerBundle AccessorOrder自定义
EN

Stack Overflow用户
提问于 2015-09-30 08:48:54
回答 1查看 221关注 0票数 0

我正在尝试使用JMSSerializerBundle注释对序列化的输出数据进行排序。我得到了这个:

代码语言:javascript
复制
use JMS\Serializer\Annotation\AccessorOrder;

/**
 * @ORM\Entity(repositoryClass="AppBundle\Entity\CustomerRepository")
 * @ExclusionPolicy("all")
 * @AccessorOrder("custom", custom = {"custom_id", "company_name", "first_name", "last_name", "email", "phone_number",
 *                          "line1", "line2", "line3", "city", "state", "postal_code", "country_code", "created_at"})
 */

/**
 * @ORM\Entity(repositoryClass="AppBundle\Entity\CustomerRepository")
 * @ExclusionPolicy("all")
 * @AccessorOrder("custom", custom = {"custom_id", "company_name", "first_name", "last_name", "email", "phone_number",
 *                          "line1", "line2", "line3", "city", "state", "postal_code", "country_code", "created_at"})
 */
class Customer {

    /**
     * @var string
     * @Expose
     */
    private $first_name;

    /**
     * @var string
     * @Expose
     */
    private $last_name;

    /**
     * @var string
     * @Expose
     */
    private $email;

    /**
     * @var string
     * @Expose
     */
    private $phone_number;

    /**
     * @var string
     * @Expose
     */
    private $company_name;

    /**
     * @var string
     * @Expose
     */
    private $line1;

    /**
     * @var string
     * @Expose
     */
    private $line2;

    /**
     * @var string
     * @Expose
     */
    private $line3;

    /**
     * @var string
     * @Expose
     */
    private $city;

    /**
     * @var string
     * @Expose
     */
    private $state;

    /**
     * @var string
     * @Expose
     */
    private $postal_code;

    /**
     * @var string
     * @Expose
     */
    private $country_code;

    /**
     * @var \DateTime
     * @Expose
     */
    private $created_at;

    /**
     * @var string
     * @Expose
     * @SerializedName("id")
     */
    private $customer_id;
}

当我提出请求时,我得到的是这样的:

代码语言:javascript
复制
{
    "id": "edf007d651855ab64f9c",
    "state": "Guanajuato",
    "created_at": "2015-09-17T12:42:21-0500",
    "company_name": "Foograde",
    "line1": "Gral. Ortega #223D",
    "first_name": "Federico",
    "city": "Celaya",
    "postal_code": "38010",
    "last_name": "Mata",
    "email": "federico.balderas@foograde.com",
    "country_code": "MX",
    "line2": "Col. Alameda"
}

你知道我做错了什么吗?

EN

回答 1

Stack Overflow用户

发布于 2015-10-01 23:31:05

似乎问题出在CocoaRestCliente响应上,Postman的响应是正确的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32856027

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档