From f5cf1fb6f3c20feac6a072558242a3b608d9c4c7 Mon Sep 17 00:00:00 2001 From: tangyao Date: Sun, 1 Nov 2015 17:43:36 +0800 Subject: [PATCH] fix: hashmap tag should be 0x4d --- lib/v2/encoder.js | 2 +- test/map.test.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/v2/encoder.js b/lib/v2/encoder.js index a9c7d28..19c5272 100644 --- a/lib/v2/encoder.js +++ b/lib/v2/encoder.js @@ -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) { diff --git a/test/map.test.js b/test/map.test.js index ef2c2a0..4480c09 100644 --- a/test/map.test.js +++ b/test/map.test.js @@ -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); @@ -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',