# JSON to Protobuf

## Description

This operation converts JSON files into [Protobuf (Protocol Buffers)](https://protobuf.dev/) 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

![](https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2FZmr35bwgundYfOW63E3q%2Fimage.png?alt=media\&token=2ba8baff-b40b-4dd4-ae2c-2a2ad5696788) - Input JSON-formatted strings.

### Output data <a href="#output-data" id="output-data"></a>

![](https://965373739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkxZeV4nlXcIAjMGZxzLI%2Fuploads%2FRDngsaxu99O216cFqn81%2Fimage.png?alt=media\&token=53e171be-7591-4c56-acdb-4e8e8646241d) - Resulting Protobuf-formatted strings.

***

## Parameters

These are the parameters you need to configure to use this operation (mandatory parameters are marked with a <mark style="color:red;">**\***</mark>):

<details>

<summary>Proto schema<mark style="color:red;"><strong>*</strong></mark></summary>

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](https://docs.onum.com/the-workspace/pipelines/actions/transformation/field-transformation/field-transformation-operations/data-format/to-base64) operation to transform your strings.

A common proto file has this structure:

```protobuf
syntax = "proto3";

message User {
  string username = 1;
  int32 age = 2;
}
```

</details>

<details>

<summary>Message type<mark style="color:red;"><strong>*</strong></mark></summary>

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:

```protobuf
syntax = "proto3";

package company;

message Employee {
  int32 id = 1;
  string name = 2;
  string role = 3;
}

message Department {
  string name = 1;
  repeated Employee employees = 2;
}
```

Enter `Employee` or `Department` to extract one of the messages.

</details>

## Example

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

1. In your Pipeline, open the required [Action](https://docs.onum.com/the-workspace/pipelines/actions) 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:

```
{ "id": 1, "name": "foo" } -> foo
```

{% hint style="info" %}
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.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.onum.com/the-workspace/pipelines/actions/transformation/field-transformation/field-transformation-operations/format-conversion/json-to-protobuf.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
