Hi guys! I need some help on something I believe should be easy but I'm not getting it right.
I want to serialise and deserialise this Table Class (vary simplified for clarity purposes):
import com.google.common.collect.LinkedHashMultimap;
public class Table {
private LinkedHashMultimap<String,Field> fields;
public Table(){
this.fields = LinkedHashMultimap.create();
};
public Table (LinkedHashMultimap<String, Field> fields){
this.fields= fields;
}
public LinkedHashMultimap<String, Field> getFields() {
return fields;
}
public void setFields(LinkedHashMultimap<String, Field> fields) {
this.fields = fields;
}
}
Before I didn't have the default constructor.
I'm aware of
this, but Im not returning a multimap, the multimap sits in the middle of a complex data structure, and the
jackson-datatype-guava dependency, which I believe is there to solve my "basic" problem.
I have added the guava module to the ObjectMapper as well, but calling readValue();
// Add guava serialization for multimaps (Table.Fields is a multimap now).
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new GuavaModule());
return mapper.readValue(response, valueType);
I've tried different approach but all of them have "polluted" my Table class with @JsonIgnore annotations, @JsonProperites with additional getters and setters to bypass multimap returning and receiving a Java Map, and then converting the map into a multimap. Since it still hasn't work and I feel I'm going in the wrong direction I'm posting my case here.
I'm sorry if this is a very naive question, It's not clear to me how should I use the jackson-datatype-guava dependency.....probably I'm just missing a good example link or a more exhaustive documentation than
JacksonModuleGuava,
JacksonFeatureModules, or the 404 page I get with the link at the bottom of the
jackson-guava github repo.
Shall I implement a serialiser, deserialiser?