A playground to develop a modern Protobuf library for Java.

Current features:

  • Java 11

  • Modular Java

  • Proto3

  • No runtime dependency on com.google.protobuf:protobuf-java, but relies on it at build time

  • The library comes with two flavors

  • Code generation through Protoc plugin

  • Java annotations supporting a subset of Protobuf as we speak

Basic usage

Creating a message

Person john = new Person()
  .setId(1234)
  .setName("John Doe")
  .setEmail("jdoe@example.com")
  .setPhones(List.of(new Person.PhoneNumber()
    .setNumber("555-4321")
    .setType(Person.PhoneType.PHONE_TYPE_HOME))
  );

Writing a Protobuf message

ProtoStream stream = ProtoWriter.streamOf(john);
byte[] protobuf = ProtobufWriter.encodeToByteArray(stream);

Reading a Protobuf message

ProtoStream stream = ProtobufReader.readerStream(MessageLiteral.Person, protobuf);
Person person = ProtoReader.readPerson(stream);

Writing a ProtoJSON message

ProtoStream stream = ProtoWriter.streamOf(john);
String json = ProtoJsonWriter.encode(stream);

Reading a ProtoJSON message

ProtoStream stream = ProtoJsonReader.readStream(MessageLiteral.Person, json);
Person person = ProtoReader.readPerson(stream);