{"id":18621254,"url":"https://github.com/sofastack/sofa-hessian-node","last_synced_at":"2025-04-11T02:31:38.069Z","repository":{"id":32688230,"uuid":"138723603","full_name":"sofastack/sofa-hessian-node","owner":"sofastack","description":"A performance improved version of Hessian powered by Ant Group.","archived":false,"fork":false,"pushed_at":"2023-12-07T02:32:23.000Z","size":123,"stargazers_count":22,"open_issues_count":1,"forks_count":12,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-25T08:22:14.049Z","etag":null,"topics":["hessian","sofa","sofa-rpc","sofastack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sofastack.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-26T10:39:53.000Z","updated_at":"2024-08-12T04:50:56.000Z","dependencies_parsed_at":"2024-06-21T13:04:46.968Z","dependency_job_id":"01a7f0a3-0be8-47cd-be28-543312be7925","html_url":"https://github.com/sofastack/sofa-hessian-node","commit_stats":null,"previous_names":["alipay/sofa-hessian-node"],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofastack%2Fsofa-hessian-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofastack%2Fsofa-hessian-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofastack%2Fsofa-hessian-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofastack%2Fsofa-hessian-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sofastack","download_url":"https://codeload.github.com/sofastack/sofa-hessian-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248329596,"owners_count":21085565,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hessian","sofa","sofa-rpc","sofastack"],"created_at":"2024-11-07T04:10:04.910Z","updated_at":"2025-04-11T02:31:33.056Z","avatar_url":"https://github.com/sofastack.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sofa-hessian-node\n蚂蚁金服对 Hessian 序列化的定制版本\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![David deps][david-image]][david-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/sofa-hessian-node.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/sofa-hessian-node\n[travis-image]: https://img.shields.io/travis/alipay/sofa-hessian-node.svg?style=flat-square\n[travis-url]: https://travis-ci.org/alipay/sofa-hessian-node\n[codecov-image]: https://codecov.io/gh/alipay/sofa-hessian-node/branch/master/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/alipay/sofa-hessian-node\n[david-image]: https://img.shields.io/david/alipay/sofa-hessian-node.svg?style=flat-square\n[david-url]: https://david-dm.org/alipay/sofa-hessian-node\n[snyk-image]: https://snyk.io/test/npm/sofa-hessian-node/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/sofa-hessian-node\n[download-image]: https://img.shields.io/npm/dm/sofa-hessian-node.svg?style=flat-square\n[download-url]: https://npmjs.org/package/sofa-hessian-node\n\nsofa-hessian-node 对应的 Java Hessian 版本是 v3.1.3。它对 [hessian.js-1](https://www.npmjs.org/package/hessian.js-1) 模块做了进一步封装，通过预编译来提高性能。\n\n## 安装\n\n```bash\n$ npm install sofa-hessian-node --save\n```\n\n## 示例\n\n```js\n'use strict';\n\n// classMap 是要序列化类的定义\nconst classMap = {\n  'com.alipay.test.sub.TestObj2': {\n    name: {\n      type: 'java.lang.String',\n    },\n    transientField: {\n      type: 'java.lang.String',\n      isTransient: true,\n    },\n    finalField: {\n      type: 'java.lang.String',\n      defaultValue: 'xxx',\n    },\n    staticField: {\n      type: 'java.lang.String',\n      isStatic: true,\n    },\n  },\n};\n\nconst encode = require('sofa-hessian-node').encode;\n\nconst buf = encode({\n  $class: 'com.alipay.test.sub.TestObj2',\n  $: { name: 'gxcsoccer' },\n}, '2.0', classMap);\n\nconsole.log(buf.toString('hex'));\n// 4fac636f6d2e616c697061792e746573742e7375622e546573744f626a3292046e616d650a66696e616c4669656c646f9009677863736f6363657203787878\n```\n\n## hessian 4 支持\n\n```js\nconst { v4 } = require('sofa-hessian-node');\n\nconst buf = v4.encode({\n  $class: 'com.alipay.test.sub.TestObj2',\n  $: { name: 'gxcsoccer' },\n}, '2.0', classMap);\n\nconsole.log(buf.toString('hex'));\n```\n\n## 性能数据\n\n从 [benchmark](benchmark/index.js) 看，相比于直接使用 hessian.js-1，sofa-hessian-node 性能有非常明显的提高（特别是针对复杂对象的场景）\n\n```bash\n  node version: v10.0.0, date: Wed Jun 27 2018 23:17:47 GMT+0800 (CST)\n  Starting...\n  4 tests completed.\n\n  hessian old - 1.0 x  47,719 ops/sec ±2.57% (86 runs sampled)\n  hessian new - 1.0 x 246,812 ops/sec ±2.76% (87 runs sampled)\n  hessian old - 2.0 x  78,132 ops/sec ±2.49% (84 runs sampled)\n  hessian new - 2.0 x 372,090 ops/sec ±2.99% (87 runs sampled)\n```\n\n## 如何贡献\n\n请告知我们可以为你做些什么，不过在此之前，请检查一下是否有已经[存在的Bug或者意见](https://github.com/alipay/sofa-hessian-node/issues)。\n\n如果你是一个代码贡献者，请参考[代码贡献规范](https://github.com/eggjs/egg/blob/master/CONTRIBUTING.zh-CN.md)。\n\n## 开源协议\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsofastack%2Fsofa-hessian-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsofastack%2Fsofa-hessian-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsofastack%2Fsofa-hessian-node/lists"}