You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Wrong serialization results while serializing object containing Map<String,Object> #229
Hello ,
I am using msgpack 0.7.0-p5 ,ObjectMapper to serialize and deserialize objects.
The problem is that i get differnent results while marshalling/unmarshalling the object.
The object of the class i am serializing is :
public class MessageData implements Serializable {
private static final long serialVersionUID = 1L;
private Map<String, Object> dataMap;
private String som;
private String accountDn;
public Map<String, Object> getDataMap() {
return dataMap;
}
public void setDataMap(Map<String, Object> dataMap) {
this.dataMap = dataMap;
}
public MessageData() {
}
public String getSom() {
return som;
}
public void setSom(String som) {
this.som = som;
}
public String getAccountDn() {
return accountDn;
}
public void setAccountDn(String accountDn) {
this.accountDn = accountDn;
}
}
when i am serializing this object the contents before serialization of the dataMap are :
MessagePack needs to know that logger is an instance of Loggers and roTimer is an instance of TransactionTimer but Map<String, Object> doesn't include those information. One option is to create and use a POJO instead of Map<String, Object> like this.
class DataMap {
public String request;
public boolean forced;
public Loggers logger;
public TransactionTimer roTimer;
:
}
DataMap dataMap = objectMapper.readValue(serializedData, DataMap.class);
Activity
komamitsu commentedon May 16, 2015
MessagePack needs to know that
loggeris an instance ofLoggersandroTimeris an instance ofTransactionTimerbutMap<String, Object>doesn't include those information. One option is to create and use a POJO instead ofMap<String, Object>like this.Anand-J-Kadhi commentedon May 21, 2015
Can you suggest any other option as this would be a lot big change this time. Like the XstreamSerilaizer(xstream.codehaus.org) serializes.
komamitsu commentedon Aug 9, 2015
@Anand-J-Kadhi Sorry for the late reply. How about storing Class information into serialized data like this ? You need to write serde, though.
This way will be available in the next release.
Anand-J-Kadhi commentedon Aug 9, 2015
Hi @komamitsu ,
No issues , Thanks for this detailed answer.