2

得到错误:

java.lang.IllegalArgumentException: Can not deserialize instance of java.lang.String out of START_OBJECT token
 at [Source: N/A; line: -1, column: -1]

Caused by: com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token
 at [Source: N/A; line: -1, column: -1]

我的实体样本:

@PersistenceCapable
public class User {
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;
    public Key getKey() {return this.key;   }
    public User()   {}
    public Address getAddress() {return address;}
    public void setAddress(Address address) {this.address = address;}
    @Persistent
    private Address address;
}

@PersistenceCapable
public class Address {
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;
@Persistent
private String otherProperty;
//Also have the set and get
}

使用 google javascript api 客户端工具 ( https://code.google.com/p/google-api-javascript-client/ )

连接到 Eclipse 中生成的 Google 云端点。- 在使用 api explorer 时,我可以添加地址没问题的用户(localhost:8888/_ah/api/explorer)。

不使用地址时,调用按预期工作:

var request = gapi.client.userendpoint.user.insert({
firstName : "test",
lastName : "test",
emailAddress : "test",
phoneNumber : "test"
});
console.log(request);
request.execute(function(resp){console.log(resp);})

但是,当使用地址调用时,它会失败:

var request2 = gapi.client.userendpoint.user.insert({
firstName : "test",
lastName : "test",
emailAddress : "test",
clubName : "test",
ahaNumber : "test",
phoneNumber : "test",
address: {
attention : "test",
line1 : "test",
line2 : "test",
line3 : "test",
state : "test",
postalCode : "test",
country : "test"
}
});
console.log(request2);
request2.execute(function(resp){console.log(resp);})

有错误:

POST http://localhost:8888/_ah/api/rpc 500 (Can not deserialize instance of java.lang.String out of START_OBJECT token  at [Source: N/A; line: -1, column: -1])

任何反馈表示赞赏!

感觉好像我错过了一些明显的东西......

4

0 回答 0