JSON to Protobuf

Description

This operation converts JSON files into Protobuf (Protocol Buffers) format. Protocol Buffers is a language-neutral, platform-neutral, extensible mechanism for serializing structured data. It's similar to JSON, but smaller and faster.


Data types

These are the input/output expected data types for this operation:

Input data

- Input JSON-formatted strings.

Output data

- Resulting Protobuf-formatted strings.


Parameters

These are the parameters you need to configure to use this operation (mandatory parameters are marked with a *):

Proto schema*

Add the schema that defines the message structure of your resulting Protobuf strings. Note that these must be formatted in Base64 or as plain text. You can use the To Base64 operation to transform your strings.

A common proto file has this structure:

syntax = "proto3";

message User {
  string username = 1;
  int32 age = 2;
}
Message type*

Enter the specific part of the message in the proto file that you want to transform into JSON format.

For example, in this proto file:

Enter Employee or Department to extract one of the messages.

Example

Suppose you want to transform your JSON files into Protobuf format. To do it:

  1. In your Pipeline, open the required Action configuration and select the input Field.

  2. In the Operation field, choose JSON to Protobuf.

  3. In the Proto schema field, enter syntax = "proto3"; message ExampleMessage { int32 id = 1; string name = 2; }

  4. In the Message type field, enter ExampleMessage

  5. Give your Output field a name and click Save. Your JSON data will be transformed. For example:

You can try out operations with specific values using the Input field above the operation. You can enter the value in the example above and check the result in the Output field.

Last updated

Was this helpful?