hessian.js-1
Advanced tools
Comparing version 1.8.4 to 1.9.0
1.9.0 / 2018-11-02 | ||
================== | ||
**features** | ||
* [[`9f32aee`](http://github.com/node-modules/hessian.js/commit/9f32aeebb6fe7da47bcab4335a2c6f463fdc5527)] - feat: support custom map type (#113) (zōng yǔ <<gxcsoccer@users.noreply.github.com>>) | ||
1.8.4 / 2018-08-30 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -258,3 +258,3 @@ /**! | ||
*/ | ||
proto._writeHashMap = function (obj) { | ||
proto._writeHashMap = function (obj, className) { | ||
debug('_writeHashMap() %j, fields: %j', obj); | ||
@@ -267,3 +267,3 @@ | ||
// hashmap's type is null | ||
this.writeType(''); | ||
this.writeType(className || ''); | ||
@@ -337,4 +337,4 @@ if (SUPPORT_ES6_MAP && obj instanceof Map) { | ||
if (!className) { | ||
return this._writeHashMap(realObj); | ||
if (!className || obj.isMap) { | ||
return this._writeHashMap(realObj, className); | ||
} | ||
@@ -341,0 +341,0 @@ |
@@ -561,3 +561,3 @@ 'use strict'; | ||
*/ | ||
proto._writeHashMap = function (obj) { | ||
proto._writeHashMap = function (obj, className) { | ||
debug('_writeHashMap() %j, fields: %j', obj); | ||
@@ -567,2 +567,8 @@ | ||
if (className) { | ||
this.byteBuffer.put(0x74); | ||
this.byteBuffer.putUInt16(className.length); | ||
this.byteBuffer.putRawString(className); | ||
} | ||
if (SUPPORT_ES6_MAP && obj instanceof Map) { | ||
@@ -569,0 +575,0 @@ obj.forEach(function (value, key) { |
{ | ||
"name": "hessian.js-1", | ||
"version": "1.8.4", | ||
"version": "1.9.0", | ||
"description": "Hessian Serialization written by pure JavaScript, support all kind of types in Java.", | ||
@@ -35,6 +35,6 @@ "main": "index.js", | ||
"byte": "^1.4.1", | ||
"debug": "^3.1.0", | ||
"is-type-of": "^1.2.0", | ||
"debug": "^3.2.6", | ||
"is-type-of": "^1.2.1", | ||
"long": "^4.0.0", | ||
"utility": "^1.14.0" | ||
"utility": "^1.15.0" | ||
}, | ||
@@ -47,6 +47,6 @@ "devDependencies": { | ||
"js-to-java": "^2.6.0", | ||
"jshint": "^2.9.5", | ||
"mm": "^2.2.2", | ||
"jshint": "^2.9.6", | ||
"mm": "^2.4.1", | ||
"mocha": "^3.5.3", | ||
"should": "^13.2.1" | ||
"should": "^13.2.3" | ||
}, | ||
@@ -53,0 +53,0 @@ "engines": { |
@@ -138,2 +138,31 @@ hessian.js-1 | ||
### Declare a custom Map type | ||
You need to declare a custom Map type with isMap property | ||
[Java example](https://github.com/mongodb/mongo-java-driver/blob/master/bson/src/main/org/bson/Document.java) | ||
```js | ||
var hessian = require('hessian.js-1'); | ||
var encoder = new hessian.Encoder(); | ||
var document = { | ||
$class: 'org.bson.Document', | ||
$: { | ||
_id: { | ||
$class: 'org.bson.Document', | ||
$: { | ||
$in: [ | ||
'5bd6a201c816e527d97cb1ad', | ||
], | ||
}, | ||
isMap: true, // mark it as a Map | ||
}, | ||
}, | ||
isMap: true, // mark it as a Map | ||
}; | ||
encoder.write(document); | ||
``` | ||
## Decoder | ||
@@ -140,0 +169,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94119
2571
421
Updateddebug@^3.2.6
Updatedis-type-of@^1.2.1
Updatedutility@^1.15.0