来自于九十的需求,如果是泛型的Map,key不是string,目前的序列化是有问题的
临时的hack方法如下(后面具体怎么改还要再想想)
// Map<Integer, PublishChannelConfig> channelConfigs = new HashMap<Integer, PublishChannelConfig>();
// hack
encoder._writeHashMap = function (obj) {
// Real code in java impl:
// http://grepcode.com/file/repo1.maven.org/maven2/com.caucho/hessian/3.1.3/com/caucho/hessian/io/Hessian2Output.java#Hessian2Output.writeMapBegin%28java.lang.String%29
// M(0x4d) type(writeType) (<key> <value>) z(0x7a)
this.byteBuffer.put(0x4d);
// hashmap's type is null
this.writeType('');
if (obj instanceof Map) {
for (let key of obj.keys()) {
this.write(key);
this.write(obj.get(key));
}
} else {
// hash map must sort keys
var keys = Object.keys(obj).sort();
for (var i = 0; i < keys.length; i++) {
var k = keys[i];
this.writeString(k);
this.write(obj[k]);
}
}
this.byteBuffer.put(0x7a);
return this;
};
来自于九十的需求,如果是泛型的Map,key不是string,目前的序列化是有问题的
临时的hack方法如下(后面具体怎么改还要再想想)