Can not deserialize instance of java.lang.String[] out of VALUE_STRING token [...] (through reference chain: [...].model.User["ethnicities"])
I have a user object with a property ethnicities.
From what I can tell the error is because the json "type" doesn't match the property type but in my case both are String arrays.
Am I doing something wrong?
Also, I can't figure out what VALUE_STRING represents in the parsing.
Server-side is using Loopback and the ethnicities property is defined as such:
"ethnicities": [
""
]
Android client is using Jackson to map the json to the pojo and vice versa. Ethnicities in pojo looks like this:
private String[] ethnicities;
public String[] getEthnicities() {return ethnicities;}
public void setEthnicities(String[] ethnicities) {this.ethnicities = ethnicities;}
The mapping to json:
try {
ObjectMapper mapper = new ObjectMapper();
jsonUserObject = mapper.writeValueAsString(user);
} catch (IOException e) {
System.out.println("IOException converting user object to JSON");
}
and the mapping from json:
try {
ObjectMapper mapper = new ObjectMapper();
user = mapper.readValue(userObjectJSON, User.class);
} catch (IOException e) {
System.out.println("IOException converting JSON to user object");
}
Here's some examples of incoming json:
"ethnicities": [
"Asian",
"American Indian",
"Hispanic"
]
"ethnicities": [
"Caucasian"
]
"ethnicities": null
Thanks!