问题
Getting error:
java.lang.IllegalArgumentException: Can not deserialize instance of java.lang.String out of START_OBJECT token
at [Source: N/A; line: -1, column: -1]
and
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]
Samples of my entities:
@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
}
Using the google javascript api client tool (https://code.google.com/p/google-api-javascript-client/)
Connecting to Google cloud endpoint generated in eclipse. -While using the api explorer, I can add users with addresses no problem(localhost:8888/_ah/api/explorer).
When not using address, the call works as expected:
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);})
However when calling with address, it fails:
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);})
with error:
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])
Any feedback is appreciated!
Feel like I'm missing something obvious...
来源:https://stackoverflow.com/questions/15193944/owned-entity-causing-json-serialization-error-in-google-javascript-api-client