{"id":13482598,"url":"https://github.com/protostuff/protostuff","last_synced_at":"2025-05-14T08:05:19.566Z","repository":{"id":13370441,"uuid":"16058167","full_name":"protostuff/protostuff","owner":"protostuff","description":"Java serialization library, proto compiler, code generator","archived":false,"fork":false,"pushed_at":"2025-04-02T04:29:11.000Z","size":5430,"stargazers_count":2071,"open_issues_count":100,"forks_count":304,"subscribers_count":94,"default_branch":"master","last_synced_at":"2025-05-07T07:59:41.994Z","etag":null,"topics":["graph","java","json","protobuf","protostuff","serialization"],"latest_commit_sha":null,"homepage":"https://protostuff.github.io","language":"Java","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/protostuff.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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":"2014-01-20T01:22:51.000Z","updated_at":"2025-05-02T20:05:19.000Z","dependencies_parsed_at":"2022-07-15T14:47:57.207Z","dependency_job_id":"7a745b13-fbbc-40cf-8915-6d8434587562","html_url":"https://github.com/protostuff/protostuff","commit_stats":{"total_commits":1481,"total_committers":40,"mean_commits":37.025,"dds":0.5719108710330858,"last_synced_commit":"13a4921f5e0e113b673b087ed5fb65ad9511e1f7"},"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protostuff%2Fprotostuff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protostuff%2Fprotostuff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protostuff%2Fprotostuff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protostuff%2Fprotostuff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/protostuff","download_url":"https://codeload.github.com/protostuff/protostuff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101588,"owners_count":22014907,"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":["graph","java","json","protobuf","protostuff","serialization"],"created_at":"2024-07-31T17:01:03.620Z","updated_at":"2025-05-14T08:05:19.549Z","avatar_url":"https://github.com/protostuff.png","language":"Java","readme":"\n![Protostuff](https://protostuff.github.io/images/protostuff_300x100.png)\n\nA java serialization library with built-in support for forward-backward compatibility (schema evolution) and validation.\n\n- **efficient**, both in speed and memory\n- **flexible**, supporting pluggable formats\n\n### Usecase\n- messaging layer in RPC\n- storage format in the datastore or cache\n\nFor more information, go to https://protostuff.github.io/docs/\n\n## Maven\n\n1. For the core formats (protostuff, protobuf, graph)\n   \n  ```xml\n  \u003cdependency\u003e\n    \u003cgroupId\u003eio.protostuff\u003c/groupId\u003e\n    \u003cartifactId\u003eprotostuff-core\u003c/artifactId\u003e\n    \u003cversion\u003e1.7.4\u003c/version\u003e\n  \u003c/dependency\u003e\n  ```\n\n2. For schemas generated at runtime\n   \n  ```xml\n  \u003cdependency\u003e\n    \u003cgroupId\u003eio.protostuff\u003c/groupId\u003e\n    \u003cartifactId\u003eprotostuff-runtime\u003c/artifactId\u003e\n    \u003cversion\u003e1.7.4\u003c/version\u003e\n  \u003c/dependency\u003e\n  ```\n\n## Usage\n```java\npublic final class Foo\n{\n    String name;\n    int id;\n    \n    public Foo(String name, int id)\n    {\n        this.name = name;\n        this.id = id;\n    }\n}\n\nstatic void roundTrip()\n{\n    Foo foo = new Foo(\"foo\", 1);\n\n    // this is lazily created and cached by RuntimeSchema\n    // so its safe to call RuntimeSchema.getSchema(Foo.class) over and over\n    // The getSchema method is also thread-safe\n    Schema\u003cFoo\u003e schema = RuntimeSchema.getSchema(Foo.class);\n\n    // Re-use (manage) this buffer to avoid allocating on every serialization\n    LinkedBuffer buffer = LinkedBuffer.allocate(512);\n\n    // ser\n    final byte[] protostuff;\n    try\n    {\n        protostuff = ProtostuffIOUtil.toByteArray(foo, schema, buffer);\n    }\n    finally\n    {\n        buffer.clear();\n    }\n\n    // deser\n    Foo fooParsed = schema.newMessage();\n    ProtostuffIOUtil.mergeFrom(protostuff, fooParsed, schema);\n}\n```\n\n## Important (for version 1.8.x)\nIf you are to purely use this to replace java serialization (no compatibility with protobuf), set the following system properties:\n```\n-Dprotostuff.runtime.always_use_sun_reflection_factory=true\n-Dprotostuff.runtime.preserve_null_elements=true\n-Dprotostuff.runtime.morph_collection_interfaces=true\n-Dprotostuff.runtime.morph_map_interfaces=true\n-Dprotostuff.runtime.morph_non_final_pojos=true\n```\n\nYou can also customize it programmatically:\n```java\nstatic final DefaultIdStrategy STRATEGY = new DefaultIdStrategy(IdStrategy.DEFAULT_FLAGS \n        | IdStrategy.PRESERVE_NULL_ELEMENTS\n        | IdStrategy.MORPH_COLLECTION_INTERFACES\n        | IdStrategy.MORPH_MAP_INTERFACES\n        | IdStrategy.MORPH_NON_FINAL_POJOS);\n```\n\nUse it:\n```java\nSchema\u003cFoo\u003e schema = RuntimeSchema.getSchema(Foo.class, STRATEGY);\n```\n\nQuestions/Concerns/Suggestions\n------------------------------\n\n- subscribe to http://groups.google.com/group/protostuff/\n\nRequirements\n------------\n\nJava 1.6 or higher\n\nBuild Requirements\n------------------\n\nMaven 3.2.3 or higher\n\nDeveloping with eclipse\n------------------\n```sh\nmvn install \u0026\u0026 mvn eclipse:eclipse\n# Open eclipse, import existing project, navigate to the protostuff module you're after, then hit 'Finish'.\n```\n","funding_links":[],"categories":["Java","Capabilities","常用框架\\\u0026第三方库"],"sub_categories":["Serialization"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotostuff%2Fprotostuff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprotostuff%2Fprotostuff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotostuff%2Fprotostuff/lists"}