{"id":20542195,"url":"https://github.com/weivea/protojson","last_synced_at":"2026-04-16T21:06:33.269Z","repository":{"id":83302540,"uuid":"145800681","full_name":"weivea/protojson","owner":"weivea","description":"一个基于约定协议的json压缩，解压缩 插件，包含java的最简实现","archived":false,"fork":false,"pushed_at":"2018-09-02T02:40:32.000Z","size":256,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-06T04:29:21.951Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weivea.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-23T04:34:26.000Z","updated_at":"2019-03-12T08:53:21.000Z","dependencies_parsed_at":"2023-07-08T03:00:24.087Z","dependency_job_id":null,"html_url":"https://github.com/weivea/protojson","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/weivea/protojson","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weivea%2Fprotojson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weivea%2Fprotojson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weivea%2Fprotojson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weivea%2Fprotojson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weivea","download_url":"https://codeload.github.com/weivea/protojson/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weivea%2Fprotojson/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31904108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"ssl_error","status_checked_at":"2026-04-16T18:21:47.142Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-11-16T01:29:45.538Z","updated_at":"2026-04-16T21:06:33.050Z","avatar_url":"https://github.com/weivea.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# proto-json\n\n一个基于约定协议的json压缩，解压缩 插件，   \n编码：根据protocal.json把json的key替换成数字；    \n解码：根据protocal.json吧编码json的 数字key再替换回来\n\n## install\n\n`npm install @weivea/proto-json`\n\n## test\n\n运行测试\n```\nnpm run test\n```\n\n## usage\n\n\n```javascript\nvar ProtoJson = require('@weivea/proto-json');\nvar protocal = {\n  width: '',\n  height: '',\n  weight: '',\n  age:'',\n  name: '',\n  partner: {\n      width: '',\n      height: '',\n      weight: '',\n      age:'',\n      name: ''\n  },\n  children: [\n      {\n          width: '',\n          height: '',\n          weight: '',\n          age:'',\n          name:'',\n          friends: [\n              {\n                  name:'',\n                  type:'',\n                  gender:''\n              }\n          ]\n      }\n  ]\n}\n\n\nvar data = {\n  width: 50,\n  height: 180,\n  weight: 50,\n  age:30,\n  name: 'lalala',\n  partner: {\n      width: 28,\n      height: 170,\n      weight: 49,\n      age:30,\n      name: 'bobo',\n      adc:'acasdv'\n  },\n  children: [\n      {\n          width: 30,\n          height: 100,\n          weight: 40,\n          age:12,\n          name:'liliya',\n          friends: [\n              {\n                  name:'tom',\n                  type:'cat'\n              },\n              {\n                  name:'bam',\n                  type:'dog'\n              }\n          ]\n      },\n      {\n          width: 45,\n          height: 160,\n          weight: 45,\n          age:15,\n          name:'tifny',\n          friends: [\n              {\n                  name:'erix',\n                  gender:'male'\n              }\n          ]\n      },\n  ]\n}\nvar dataStr = JSON.stringify(data);\nconsole.log('原数据:', dataStr);\nconsole.log('');\n\nvar protoJsoner = new ProtoJson(protocal);\n\nvar encodejson = protoJsoner.encode(data);\nconsole.log('编码数据:', JSON.stringify(encodejson));\nconsole.log('');\n\nvar decodejson = protoJsoner.decode(encodejson);\nconsole.log('解码数据:', JSON.stringify(decodejson));\n\n```\n\n打印输出：\n\n```\n原数据: {\"width\":50,\"height\":180,\"weight\":50,\"age\":30,\"name\":\"lalala\",\"partner\":{\"width\":28,\"height\":170,\"weight\":49,\"age\":30,\"name\":\"bobo\",\"adc\":\"acasdv\"},\"children\":[{\"width\":30,\"height\":100,\"weight\":40,\"age\":12,\"name\":\"liliya\",\"friends\":[{\"name\":\"tom\",\"type\":\"cat\"},{\"name\":\"bam\",\"type\":\"dog\"}]},{\"width\":45,\"height\":160,\"weight\":45,\"age\":15,\"name\":\"tifny\",\"friends\":[{\"name\":\"erix\",\"gender\":\"male\"}]}]}\n\n编码数据: {\"1\":30,\"2\":[{\"1\":12,\"2\":[{\"2\":\"tom\",\"3\":\"cat\"},{\"2\":\"bam\",\"3\":\"dog\"}],\"3\":100,\"4\":\"liliya\",\"5\":40,\"6\":30},{\"1\":15,\"2\":[{\"1\":\"male\",\"2\":\"erix\"}],\"3\":160,\"4\":\"tifny\",\"5\":45,\"6\":45}],\"3\":180,\"4\":\"lalala\",\"5\":{\"1\":30,\"2\":170,\"3\":\"bobo\",\"4\":49,\"5\":28,\"adc\":\"acasdv\"},\"6\":50,\"7\":50}\n\n解码数据: {\"age\":30,\"children\":[{\"age\":12,\"friends\":[{\"name\":\"tom\",\"type\":\"cat\"},{\"name\":\"bam\",\"type\":\"dog\"}],\"height\":100,\"name\":\"liliya\",\"weight\":40,\"width\":30},{\"age\":15,\"friends\":[{\"gender\":\"male\",\"name\":\"erix\"}],\"height\":160,\"name\":\"tifny\",\"weight\":45,\"width\":45}],\"height\":180,\"name\":\"lalala\",\"partner\":{\"age\":30,\"height\":170,\"name\":\"bobo\",\"weight\":49,\"width\":28,\"adc\":\"acasdv\"},\"weight\":50,\"width\":50}\n\n```\n\n\n## java 端 的最简实践\n\n命令查看测试结果\n```\njavac -cp ./:./protojsonjava/lib/gson.jar protojsonjava/TestJSON.java\n\njava -cp ./:./protojsonjava/lib/gson.jar protojsonjava/TestJSON\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweivea%2Fprotojson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweivea%2Fprotojson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweivea%2Fprotojson/lists"}