I can post for community which has the same problem as userprofile.
Nothing is returned to s since it crashes the program.
Code:
s = getRestTemplate().postForObject(communityURL, newCommunity, String.class);
I believe it is fine to deserialize / serialize in the same mixin association? Here is what that looks like.
Code:
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(using=CommunitySerializer.class)
@JsonDeserialize(using=CommunityDeserializer.class)
public class CommunityMixin {
static class CommunityDeserializer extends JsonDeserializer<List<Community>> {
@Override
public List<Community> deserialize(JsonParser jp, DeserializationContext context) throws IOException, JsonProcessingException {
JsonNode tree = jp.readValueAsTree();
List<ommunity> communities = new LinkedList<Community>();
for(JsonNode j : tree.findValues("data")){
communities.add(new Community(j.get("id").getValueAsLong(), j.get("name").getValueAsText(), j.get("description").getValueAsText() , j.get("shortName").getValueAsText(), j.get("userCount").getValueAsLong(), j.get("stateChangedDate").getValueAsLong(), j.get("liveDate").getValueAsLong()));
}
return communities;
}
}
static class CommunitySerializer extends JsonSerializer<Community> {
@Override
public void serialize(Community value, JsonGenerator jgen,
SerializerProvider provider) throws IOException,
JsonProcessingException {
// TODO Auto-generated method stub
Community q = value;
jgen.writeStartObject();
jgen.writeStringField("name", q.getName());
jgen.writeStringField("description", q.getDescription());
jgen.writeEndObject();
jgen.close();
}
}
}