Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here


Statistics on jackson-datatype-protobuf

Number of watchers on Github 38
Number of open issues 0
Average time to close an issue 23 days
Main language Java
Average time to merge a PR 3 days
Open pull requests 1+
Closed pull requests 5+
Last commit over 1 year ago
Repo Created almost 6 years ago
Repo Last Updated over 1 year ago
Size 388 KB
Organization / Authorhubspot
Latest Releasejackson-datatype-protobuf-0.9.6-preJackson27
Contributors2
Page Updated
Do you use jackson-datatype-protobuf? Leave a review!
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating jackson-datatype-protobuf for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

Overview

Jackson module that adds support for serializing and deserializing Google's Protocol Buffers to and from JSON.

Usage

Maven dependency

To use module on Maven-based projects, use following dependency:

<dependency>
  <groupId>com.hubspot.jackson</groupId>
  <artifactId>jackson-datatype-protobuf</artifactId>
  <version><!-- see table below --></version>
</dependency>

Versions

There are separate versions based on which version of Jackson you are using, as well as which version of protobuf (proto2 vs. proto3). The follow table shows which version to use based on these factors:

Jackson <= 2.6.x Jackson 2.7.x Jackson 2.8.x Jackson 2.9.x
Protobuf 2.x 0.9.9-preJackson2.7-proto2 0.9.9-jackson2.7-proto2 0.9.9-jackson2.8-proto2 0.9.9-jackson2.9-proto2
Protobuf 3.x 0.9.9-preJackson2.7-proto3 0.9.9-jackson2.7-proto3 0.9.9-jackson2.8-proto3 0.9.9-jackson2.9-proto3

Protobuf 3 Support

As noted above, if you are using Protobuf3 there is a separate version of the library to use. It has support for all of the Protobuf 3 features and built-in types. The JSON representation should match the encoding specified here, with a few exceptions:

  • int64, fixed64, uint64 are written as JSON numbers instead of strings
  • Any objects don't have any special handling, so the value will be a base64 string, and the type URL field name is typeUrl instead of @type

Compared to Protobuf2 behavior, the main difference is that field presence is only supported for Message fields. This means we can't tell if a primitive field was explicitly set to its default value, or not set at all. So for Protobuf3 messages, the library will write primitive fields that are set to default values. If you want to disable this, you can set your JSON inclusion to Include.NON_DEFAULT. Currently you need to set this inclusion globally, but we could make it more granular in the future.

Registering module

Registration is done as follows:

ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new ProtobufModule());

after which functionality is available for all normal Jackson operations.

jackson-datatype-protobuf open issues Ask a question     (View All Issues)
  • almost 3 years protocol buffer maps are serialized as key-value lists
  • about 3 years Booleans and enums represented as 0 show up as null in JSON
  • over 3 years Extension Fields are missing in json representation
jackson-datatype-protobuf open pull requests (View All Pulls)
  • Add ProtobufClassIntrospector
jackson-datatype-protobuf list of languages used
Other projects in Java