All Projects → protostuff → Protostuff

protostuff / Protostuff

Licence: apache-2.0
Java serialization library, proto compiler, code generator

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Protostuff

Kotlinx.serialization
Kotlin multiplatform / multi-format serialization
Stars: ✭ 3,550 (+105.2%)
Mutual labels:  json, protobuf, serialization
Shineframe
高性能超轻量级C++开发库及服务器编程框架
Stars: ✭ 274 (-84.16%)
Mutual labels:  json, protobuf, serialization
Go
A high-performance 100% compatible drop-in replacement of "encoding/json"
Stars: ✭ 10,248 (+492.37%)
Mutual labels:  json, serialization
Java
jsoniter (json-iterator) is fast and flexible JSON parser available in Java and Go
Stars: ✭ 1,308 (-24.39%)
Mutual labels:  json, serialization
Json
Lighter and Faster Json Serialization tool.
Stars: ✭ 128 (-92.6%)
Mutual labels:  json, serialization
Dahomey.json
The main purpose of this library is to bring missing features to the official .Net namespace System.Text.Json
Stars: ✭ 84 (-95.14%)
Mutual labels:  json, serialization
Coq Serapi
Coq Protocol Playground with Se(xp)rialization of Internal Structures.
Stars: ✭ 87 (-94.97%)
Mutual labels:  json, serialization
Protobuf
Protocol Buffers - Google's data interchange format
Stars: ✭ 52,305 (+2923.41%)
Mutual labels:  protobuf, serialization
Json Mobx
Simple undo/redo and persistence for MobX
Stars: ✭ 78 (-95.49%)
Mutual labels:  json, serialization
Datafiles
A file-based ORM for Python dataclasses.
Stars: ✭ 113 (-93.47%)
Mutual labels:  json, serialization
Schema Registry
Confluent Schema Registry for Kafka
Stars: ✭ 1,647 (-4.8%)
Mutual labels:  json, protobuf
Symfony Jsonapi
JSON API Transformer Bundle for Symfony 2 and Symfony 3
Stars: ✭ 114 (-93.41%)
Mutual labels:  json, serialization
Bitcoin Scraper
💲 bitcoin chart history scraper
Stars: ✭ 80 (-95.38%)
Mutual labels:  graph, json
Jsonifier
Fast and simple JSON encoding toolkit
Stars: ✭ 79 (-95.43%)
Mutual labels:  json, serialization
Protobuf Nim
Protobuf implementation in pure Nim that leverages the power of the macro system to not depend on any external tools
Stars: ✭ 90 (-94.8%)
Mutual labels:  protobuf, serialization
Dartson
Dartson is a Dart library that can be used to convert Dart objects into a JSON string.
Stars: ✭ 78 (-95.49%)
Mutual labels:  json, serialization
Fast Serialization
FST: fast java serialization drop in-replacement
Stars: ✭ 1,348 (-22.08%)
Mutual labels:  json, serialization
Rust Protobuf
Rust implementation of Google protocol buffers
Stars: ✭ 1,797 (+3.87%)
Mutual labels:  protobuf, serialization
Dictfier
Python library to convert/serialize class instances(Objects) both flat and nested into a dictionary data structure. It's very useful in converting Python Objects into JSON format
Stars: ✭ 67 (-96.13%)
Mutual labels:  json, serialization
React Json Graph
React component for rendering graphs
Stars: ✭ 71 (-95.9%)
Mutual labels:  graph, json

Protostuff

A java serialization library with built-in support for forward-backward compatibility (schema evolution) and validation.

  • efficient, both in speed and memory
  • flexible, supporting pluggable formats

Usecase

  • messaging layer in RPC
  • storage format in the datastore or cache

For more information, go to https://protostuff.github.io/docs/

Maven

  1. For the core formats (protostuff, protobuf, graph)
<dependency>
  <groupId>io.protostuff</groupId>
  <artifactId>protostuff-core</artifactId>
  <version>1.7.4</version>
</dependency>
  1. For schemas generated at runtime
<dependency>
  <groupId>io.protostuff</groupId>
  <artifactId>protostuff-runtime</artifactId>
  <version>1.7.4</version>
</dependency>

Usage

public final class Foo
{
    String name;
    int id;
    
    public Foo(String name, int id)
    {
        this.name = name;
        this.id = id;
    }
}

static void roundTrip()
{
    Foo foo = new Foo("foo", 1);

    // this is lazily created and cached by RuntimeSchema
    // so its safe to call RuntimeSchema.getSchema(Foo.class) over and over
    // The getSchema method is also thread-safe
    Schema<Foo> schema = RuntimeSchema.getSchema(Foo.class);

    // Re-use (manage) this buffer to avoid allocating on every serialization
    LinkedBuffer buffer = LinkedBuffer.allocate(512);

    // ser
    final byte[] protostuff;
    try
    {
        protostuff = ProtostuffIOUtil.toByteArray(foo, schema, buffer);
    }
    finally
    {
        buffer.clear();
    }

    // deser
    Foo fooParsed = schema.newMessage();
    ProtostuffIOUtil.mergeFrom(protostuff, fooParsed, schema);
}

Important (for version 1.8.x)

If you are to purely use this to replace java serialization (no compatibility with protobuf), set the following system properties:

-Dprotostuff.runtime.always_use_sun_reflection_factory=true
-Dprotostuff.runtime.preserve_null_elements=true
-Dprotostuff.runtime.morph_collection_interfaces=true
-Dprotostuff.runtime.morph_map_interfaces=true
-Dprotostuff.runtime.morph_non_final_pojos=true

You can also customize it programmatically:

static final DefaultIdStrategy STRATEGY = new DefaultIdStrategy(IdStrategy.DEFAULT_FLAGS 
        | IdStrategy.PRESERVE_NULL_ELEMENTS
        | IdStrategy.MORPH_COLLECTION_INTERFACES
        | IdStrategy.MORPH_MAP_INTERFACES
        | IdStrategy.MORPH_NON_FINAL_POJOS);

Use it:

Schema<Foo> schema = RuntimeSchema.getSchema(Foo.class, STRATEGY);

Questions/Concerns/Suggestions

Requirements

Java 1.6 or higher

Build Requirements

Maven 3.2.3 or higher

Developing with eclipse

mvn install && mvn eclipse:eclipse
# Open eclipse, import existing project, navigate to the protostuff module you're after, then hit 'Finish'.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].