我的Google云端点在帖子正文中收到一个对象,当将JSON转换为实际的Java对象时,大部分字段都是空的。似乎端点API没有考虑像@SerializedName
这样的gson注释public class MyObject{
@SerializedName("production_unit_ID")
private Long productionUnitId;
...
getters / setters
}
API:
@ApiMethod(name = "puMyObject", httpMethod = "put", path = "putMyObject")
public MyObject putWorkOrder(HttpServletRequest req, MyObject myobj) {
myobj.getProductionUnitId(); // <-- null
在我的pom.xml中,我根据文档的要求添加了以下依赖项:
https://developers.google.com/api-client-library/java/google-http-java-client/app-engine
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
<version>1.23.0</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-gson</artifactId>
<version>1.23.0</version>
</dependency>