/protobuf-pojo-jackson-serialization

Sample project that demonstrates how to use Jackson to convert a POJO with a Protobuf Message field to JSON

Primary LanguageJavaApache License 2.0Apache-2.0

Repository containing the sample application for the blog post Convert Java POJO With Protobuf Field to JSON Using Jackson.

The following steps explain how to compile the Protobuf message file to Java, run the demo application, and query the REST endpoint.

Execute Protobuf compiler:

protoc.exe \
    --java_out=src/main/java \
    src/main/resources/protobuf/AwesomePowerUp.proto

Run the application:

mvn spring-boot:run

Query the /awesome endpoint and feel empowered:

> curl -i http://localhost:8080/awesome

HTTP/1.1 200
Content-Type: application/json
Transfer-Encoding: chunked
Date: Tue, 16 Feb 2021 17:10:36 GMT

{
  "status":"Everything is AWESOME, when you're part of a team <sing>",
  "awesomePowerUp": {
    "name": "Extra Armor",
    "level": 100
  }
}