{"id":19662713,"url":"https://github.com/brunexgeek/protogen","last_synced_at":"2025-06-18T09:37:04.609Z","repository":{"id":70676429,"uuid":"161686198","full_name":"brunexgeek/protogen","owner":"brunexgeek","description":"Compile proto3 to generate C++ code for JSON serialization","archived":false,"fork":false,"pushed_at":"2024-12-17T23:49:07.000Z","size":416,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-16T07:08:09.045Z","etag":null,"topics":["compiler","cpp","json","json-generator","json-schema","protobuf3","serialization","single-file"],"latest_commit_sha":null,"homepage":"https://brunocosta.net.br/project/protogen/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brunexgeek.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-12-13T19:34:41.000Z","updated_at":"2025-06-05T10:04:24.000Z","dependencies_parsed_at":"2024-05-05T20:28:06.303Z","dependency_job_id":"461d918b-726d-414c-b34f-c4a3d13e033f","html_url":"https://github.com/brunexgeek/protogen","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/brunexgeek/protogen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunexgeek%2Fprotogen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunexgeek%2Fprotogen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunexgeek%2Fprotogen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunexgeek%2Fprotogen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brunexgeek","download_url":"https://codeload.github.com/brunexgeek/protogen/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunexgeek%2Fprotogen/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260248068,"owners_count":22980728,"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":["compiler","cpp","json","json-generator","json-schema","protobuf3","serialization","single-file"],"created_at":"2024-11-11T16:12:10.617Z","updated_at":"2025-06-18T09:36:59.583Z","avatar_url":"https://github.com/brunexgeek.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# protogen [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fbrunexgeek%2Fprotogen%2Fbadge%3Fref%3Dmaster\u0026label=build\u0026logo=none)](https://actions-badge.atrox.dev/brunexgeek/protogen/goto?ref=master)\n\nProtogen is a tool designed to streamline the process of serializing and deserializing data as JSON within C++ programs. Data models are defined using a subset of [proto3](https://protobuf.dev/programming-guides/proto3/) syntax and the protogen tool automatically generate C++ code for serialization and deserialization operations. The generated code requires a C++11-capable compiler and has no external dependencies. Both the compiler and the generated code are distributed under the permissive [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).\n\n## Build\n\n```\n# mkdir build \u0026\u0026 cd build\n# cmake ..\n# make\n```\n\n## Usage\n\nCreate a ``.proto`` file:\n\n```\nsyntax = \"proto3\";\n\nmessage Person {\n    string name = 1;\n    int32 age = 2;\n    repeated string pets = 3;\n}\n```\n\nCompile ``.proto`` files using ``protogen`` program:\n\n```\n# ./protogen model.proto model.pg.hh\n```\n\nInclude the generated header file in your source code and use it. That's all!\n\n```c++\n#include \"model.pg.hh\"\n\n...\n\n// create and populate an object\nPerson person1;\nperson1.name = \"이주영\";\nperson1.age = 32;\nperson1.pets.push_back(\"티그\");\n\n// JSON serialization\nstd::string json;\nif (!person1.serialize(json))\n   std::cerr \u003c\u003c \"Error\" \u003c\u003c std::endl;\n\n// JSON deserialization\nPerson person2;\nif (!person2.deserialize(json))\n    std::cerr \u003c\u003c \"Error\" \u003c\u003c std::endl;\nelse\n    std::cout \u003c\u003c person2.name \u003c\u003c std::endl;\n\n// JSON deserialization with parameters and error information (optional)\nPerson person3;\nprotogen_3_0_0::Parameters params;\nif (!person3.deserialize(json, \u0026params))\n    std::cerr \u003c\u003c \"Error: \" \u003c\u003c params.error.message \u003c\u003c \" at \" \u003c\u003c params.error.line\n        \u003c\u003c ':' \u003c\u003c params.error.column \u003c\u003c std::endl;\nelse\n    std::cout \u003c\u003c person3.name \u003c\u003c std::endl;\n\n...\n```\n\nCompile the program as usual. In the example above, the output would be:\n\n```\n{\"name\":\"이주영\",\"age\":32,\"pets\":[\"티그\"]}\n이주영\n이주영\n```\n\nTypes generated by protogen compiler contain helper functions like ``clear``, ``empty`` and comparison operators.\n\n## Supported proto3 options\n\nThese options can be set in the `proto3` file:\n\n* **obfuscate_strings** (top-level) \u0026ndash; Enable string obfuscation. If enabled, all strings in the C++ generated file will be obfuscated with a very simple (and insecure) algorithm. The default value is `false`. This option can be used to make a little difficult for curious people to find out your JSON field names by inspecting binary files.\n* **number_names** (top-level) \u0026ndash; Use field numbers as JSON field names. The default value is `false`. If enabled, every JSON field name will be the number of the corresponding field in the `.proto` file. This can reduce significantly the size of the JSON output.\n* **transient** (field-level) \u0026ndash; Make the field transient (`true`) or not (`false`). Transient fields are not serialized/deserialized. The default value is `false`.\n* **cpp_use_lists** (top-level) \u0026ndash; Use `std::list` (`true`) instead of `std::vector` (`false`) in repeated fields. This gives best performance if your program constantly changes repeated fields (add and/or remove items). This option does not affect `bytes` fields which always use `std::vector`. The default value is `false` (i.e. use `std::vector`).\n* **name** (field-level) \u0026ndash; Specify a custom name for the JSON field, while retaining the C++ field name as defined in the message. If no custom name is provided, the JSON field and the C++ field name will be the same.\n\n## Features\n\nSupported field types:\n- [x] messages (see [Limitations](#Limitations))\n- [x] repeated\n- [x] optional - Fields are always optional, but the syntax is accepted for completeness.\n- [x] double, float\n- [x] int32, sint32, uint32, fixed32, sfixed32\n- [x] int64, sint64, uint64, fixed64, sfixed64\n- [x] bool\n- [x] string\n- [x] bytes\n- [ ] any\n- [ ] oneof - The compiler **do not** actually supports it, but you can have a similar behavior by calling `empty` to check whether a field is present.\n- [ ] map\n\nProto3 syntax features:\n- [x] Line and block comments\n- [x] Packages\n- [ ] Imports\n- [x] Options\n- [ ] Nested messages\n- [ ] Enumerations\n\n## Type mapping\n\nThe following table maps `proto3` types with their corresponding C++ types in generated code. In the namespace `protogen_x_y_z`, the part `x_y_z` will be replaced by the current version number.\n\nproto3     | C++\n-----------|----\n`message`  | `class`\n`repeated` | `std::vector` or `std::list`\n`double`   | `protogen_x_y_z::field\u003cdouble\u003e`\n`float`    | `protogen_x_y_z::field\u003cfloat\u003e`\n`int32`    | `protogen_x_y_z::field\u003cint32_t\u003e`\n`sint32`   | `protogen_x_y_z::field\u003cint32_t\u003e`\n`uint32`   | `protogen_x_y_z::field\u003cuint32_t\u003e`\n`int64`    | `protogen_x_y_z::field\u003cint64_t\u003e`\n`sint64`   | `protogen_x_y_z::field\u003cint64_t\u003e`\n`uint64`   | `protogen_x_y_z::field\u003cuint64_t\u003e`\n`fixed32`  | `protogen_x_y_z::field\u003cuint32_t\u003e`\n`fixed64`  | `protogen_x_y_z::field\u003cuint64_t\u003e`\n`sfixed32` | `protogen_x_y_z::field\u003cint32_t\u003e`\n`sfixed64` | `protogen_x_y_z::field\u003cint64_t\u003e`\n`bool`     | `protogen_x_y_z::field\u003cbool\u003e`\n`string`   | `protogen_x_y_z::string_field`\n`bytes`    | `std::vector\u003cuint8_t\u003e`\n\nSome considerations:\n- `optional` is accepted only for compatibility since everything is always optional in protogen and all field types have the `empty` function to check its presence.\n- Exact precision for 64-bit integers (e.g. int64, uint64) is guaranteed only when using up to 53 bits, since JSON numbers are always [IEEE-754 doubles](https://en.wikipedia.org/wiki/Double-precision_floating-point_format#Precision_limitations_on_integer_values).\n- C++ integer types are defined by `\u003ccstdint\u003e`.\n\n## Limitations\n\nThese are the current limitations of the implementation. Some of them may be removed in future versions.\n\nProto3 parser:\n- Circular references are not supported;\n\n## License\n\nThe library and the compiler are distributed under [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).\n\nCode generated by **protogen** compiler is distributed under [The Unlicense](http://unlicense.org), but it depends on Protogen code which is licensed under [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunexgeek%2Fprotogen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrunexgeek%2Fprotogen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunexgeek%2Fprotogen/lists"}