Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hashmap tag should be 0x4d #53

Merged
merged 1 commit into from
Nov 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/v2/encoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ proto._writeListBegin = function (length, type) {
proto._writeHashMap = function (obj) {
debug('_writeHashMap() %j, fields: %j', obj);

this.byteBuffer.put(0x48); // H
this.byteBuffer.put(0x4d); // M

if (SUPPORT_ES6_MAP && obj instanceof Map) {
obj.forEach(function (value, key) {
Expand Down
6 changes: 3 additions & 3 deletions test/map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ describe('map.test.js', function () {
// pass if not support es6 Map
return;
}
var generic = new Buffer('48f87bd5e2403de240c87b7a', 'hex');
var generic = new Buffer('4df87bd5e2403de240c87b7a', 'hex');
var map = new Map();
map.set({ '$class': 'java.lang.Long', '$': 123 }, 123456);
map.set({ '$class': 'java.lang.Long', '$': 123456 }, 123);
Expand Down Expand Up @@ -278,14 +278,14 @@ describe('map.test.js', function () {

it('should write js object to no type hash map', function () {
var encoder = new hessian.EncoderV2();
var fooEmpty = new Buffer('4803666f6f007a', 'hex');
var fooEmpty = new Buffer('4d03666f6f007a', 'hex');
var buf = encoder.write({ foo: '' }).get();
buf.should.eql(fooEmpty);
hessian.decode(fooEmpty, '2.0').should.eql({
foo: ''
});

var fooBar = new Buffer('4803313233c9c803666f6f03626172047a65726f9005e4b8ade696876b657909e4b8ade69687e59388e5938876616c75657a', 'hex');
var fooBar = new Buffer('4d03313233c9c803666f6f03626172047a65726f9005e4b8ade696876b657909e4b8ade69687e59388e5938876616c75657a', 'hex');
encoder = new hessian.EncoderV2();
buf = encoder.write({
foo: 'bar',
Expand Down