我正在尝试使用JMSSerializerBundle注释来排序序列化的输出数据。我明白了:
use JMSSerializerAnnotationAccessorOrder;
/**
* @ORMEntity(repositoryClass="AppBundleEntityCustomerRepository")
* @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"})
*/
/**
* @ORMEntity(repositoryClass="AppBundleEntityCustomerRepository")
* @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;
}
当我发出请求时,我得到这个:
{
"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"
}
你知道我做错了什么吗?
似乎问题是cocoarestclient响应,与Postman响应是正确的。