{"id":25171381,"url":"https://github.com/basemax/firstprotobufjs","last_synced_at":"2025-04-03T21:21:19.542Z","repository":{"id":38470880,"uuid":"445478176","full_name":"BaseMax/FirstProtobufJS","owner":"BaseMax","description":"A quick and practical look at Protobuf. If you know what is JSON and how its work, you can see how much Proto-Buf is easy.","archived":false,"fork":false,"pushed_at":"2024-04-10T21:47:04.000Z","size":65,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T17:08:05.894Z","etag":null,"topics":["javascript","js","proto","proto3","protobuf","protobuf-compiler","protobuf-example","protobuf-js","protobuf3","protobuff","protobufjs","protof"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BaseMax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-07T10:11:04.000Z","updated_at":"2022-02-22T14:38:46.000Z","dependencies_parsed_at":"2022-08-24T08:11:31.281Z","dependency_job_id":null,"html_url":"https://github.com/BaseMax/FirstProtobufJS","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FFirstProtobufJS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FFirstProtobufJS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FFirstProtobufJS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FFirstProtobufJS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BaseMax","download_url":"https://codeload.github.com/BaseMax/FirstProtobufJS/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247079296,"owners_count":20880030,"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":["javascript","js","proto","proto3","protobuf","protobuf-compiler","protobuf-example","protobuf-js","protobuf3","protobuff","protobufjs","protof"],"created_at":"2025-02-09T09:20:00.391Z","updated_at":"2025-04-03T21:21:19.523Z","avatar_url":"https://github.com/BaseMax.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# First Protobuf (`.proto`) Javascript\n\n### A quick and practical look at Protobuf. \n\nIf you know what is **JSON** and how its work, you can see how much **Proto-Buf** is easy.\n\nWhat you dont know you think its hard but when you start to test and working on, you will see its easy.\n\n- First example implenment using JSON at `json.js` file,\n- And next same example implenment using Protobuf inside `protobuf.js` file.\n\n## Build proto scheme\n\n```bash\n$ protoc --js_out=import_style=commonjs,binary:. employees.proto\n```\n\n### Compare JSON and Protobuf Data size\n\n\u003e [max@workstation grpc-series-protobuf-js]$ ls -al\n\n| Size |   Filename    | Method   |\n|------|---------------|----------|\n| 123  | employees.json| JSON     |\n| 48   | employees.bin | Protobuf |\n\n## Output of examples\n\n\u003e [max@workstation grpc-series-protobuf-js]$ node protobuf.js \n\n```\nAli name is: ALI\nReza name is: REZA\nJavad name is: JAVAD\nData: 1001,ALI,50001,1002,REZA,50002,1003,JAVAD,50003\nBinary: 10,13,8,233,7,18,3,65,76,73,29,0,81,67,71,10,14,8,234,7,18,4,82,69,90,65,29,0,82,67,71,10,15,8,235,7,18,5,74,65,86,65,68,29,0,83,67,71\nRead data from bytes: 1001,ALI,50001,1002,REZA,50002,1003,JAVAD,50003\n```\n\n\u003e [max@workstation grpc-series-protobuf-js]$ node json.js \n\n```\nAli name is: ALI\nReza name is: REZA\nJavad name is: JAVAD\nData: [object Object],[object Object],[object Object]\nJSON: [{\"id\":1001,\"name\":\"ALI\",\"salary\":50001},{\"id\":1002,\"name\":\"REZA\",\"salary\":50002},{\"id\":1003,\"name\":\"JAVAD\",\"salary\":50003}]\nRead data from JSON: [object Object],[object Object],[object Object]\n```\n\n## Download `protoc`\n\nYou need to install `protoc` program on your system, you can download it from https://github.com/protocolbuffers/protobuf/releases depends on your Operation system. whatever your system is Liunx, Windows or OSX.\n\nNext you can run `bin/protoc` by typing its full path.\n\nFor example:\n\n```bash\n$ /to-the-path/bin/protoc --js_out=import_style=commonjs,binary:. /your-source-path/employees.proto\n```\n\n### Setup protoc globally on your system\n\nIf you want to install/setup it globally you have to put `bin` and `include` directory to your system directory.\n\nYou need to copy these directory to the system **dir**:\n- `bin` -\u003e `/usr/bin/`\n- `include` -\u003e `/usr/include/`\n\nMaybe, A command to help you:\n\n```bash\n$ cp -a * /usr/\n```\n\n## Go next\n\nIf you want to learn protobuf funcitonally deeply, you can check and read the generated file by Protoc at [`employees_pb.js`](employees_pb.js). [c](https://www.youtube.com/watch?v=46O73On0gyI)\n\n- https://github.com/protobufjs/protobuf.js/\n- https://www.npmjs.com/package/protobufjs\n- https://www.npmjs.com/package/@apollo/protobufjs\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Ffirstprotobufjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasemax%2Ffirstprotobufjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Ffirstprotobufjs/lists"}