> For the complete documentation index, see [llms.txt](https://docs.frends.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.frends.com/tasks/tasks/avro/serialize.md).

# Serialize

Serializes JSON data into Avro binary format and saves it to a file.

Task version: 2.1.0

Required Frends version: 5.7+

Required .NET version: 8.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.Avro>

## Task Parameters

{% tabs %}
{% tab title="Input" %}

| Name                      | Description                                                                                                                                                                                                                                                                                                                                                                                                               |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Json : `String`           | <p>Input JSON string that can be both single objects and arrays of objects.</p><p>The JSON data will be serialized according to the provided Avro schema.</p><p><br>Default: <code>-</code><br>Example: <code>Single object: { "name": "Jerry", "age": 30, "city": "New York" } Array of objects: \[{ "name": "John", "age": 30 }, { "name": "Jane", "age": 25 }]</code></p>                                              |
| Schema : `String`         | <p>Avro Schema definition in JSON format that defines the structure of the data to be serialized.</p><p>Must be a valid Avro schema that matches the structure of the input JSON data.</p><p><br>Default: <code>-</code><br>Example: <code>{ "type": "record", "name": "Person", "fields": \[ { "name": "name", "type": "string" }, { "name": "age", "type": "int" }, { "name": "city", "type": "string" } ] }</code></p> |
| TargetFilePath : `String` | <p>Full path to the target file where the serialized Avro data will be stored.</p><p>The directory must exist and the file must not already exist (unless overwrite is enabled).</p><p><br>Default: <code>-</code><br>Example: <code>Windows: C:\data\output\myfile.avro Linux/Mac: /home/user/data/myfile.avro</code></p>                                                                                                |
| {% endtab %}              |                                                                                                                                                                                                                                                                                                                                                                                                                           |

{% tab title="Options" %}

| Name                             | Description                                                                                                                                                                                                                                                                                                                                  |
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ThrowErrorOnFailure : `Boolean`  | <p>Determines error handling behavior. If true, throws an exception when serialization fails.</p><p>If false, returns error information in the Result object instead of throwing.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                                                     |
| ErrorMessageOnFailure : `String` | <p>Custom error message to use when ThrowErrorOnFailure is false and an error occurs.</p><p>If null or empty, the original exception message will be used.</p><p>This allows for user-friendly error messages in automated workflows.</p><p><br>Default: <code>-</code><br>Example: <code>Failed to serialize data to Avro format</code></p> |
| {% endtab %}                     |                                                                                                                                                                                                                                                                                                                                              |
| {% endtabs %}                    |                                                                                                                                                                                                                                                                                                                                              |

## Task Result

| Name                            | Description                                                                                                                                                                                                                                                                                                                                                                                                            |
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Success : `Boolean`             | <p>Indicates whether the serialization operation completed successfully. True if the JSON data was successfully serialized to Avro format, false if an error occurred.<br>Example: <code>true</code></p>                                                                                                                                                                                                               |
| FilePath : `String`             | <p>Full path to the created Avro file when serialization is successful. Empty string when serialization fails.<br>Example: <code>C:\results\myfile.avro</code></p>                                                                                                                                                                                                                                                     |
| Error : `Error`                 | <p>Error information when the serialization task fails and ThrowErrorOnFailure option is set to false. Contains detailed error message and additional debugging information. Null when the operation succeeds or when ThrowErrorOnFailure is true.<br>Example: <code>{ "Message": "Field 'name' is missing in the JSON.", "AdditionalInfo": { "ExceptionType": "AvroTypeException", "StackTrace": "..." } }</code></p> |
| Error.Message : `String`        | <p>Primary error message describing what went wrong during serialization. Can be either the original exception message or a custom message if specified in options.<br>Example: <code>Field 'name' is missing in the JSON.</code></p>                                                                                                                                                                                  |
| Error.AdditionalInfo : `Object` | <p>Additional contextual information about the error such as exception type and stack trace. Contains structured data that can be useful for automated error handling and logging.<br>Example: <code>{ "ExceptionType": "ArgumentException", "StackTrace": "..." }</code></p>                                                                                                                                          |

## Task Changelog

Changelog for Task Frends.Avro.Serialize.

### \[2.1.0] - 2026-07-17

#### Fixed

* Added missing documentation example for the Error result property.

### \[2.0.0] - 2025-08-07

#### Changed

* \[Breaking] Renamed `OutputPath` parameter to `TargetFilePath` in Input tab
* Updated Result structure to include Success boolean and Error object

#### Added

* Added new Options tab with error handling parameters (ThrowErrorOnFailure, ErrorMessageOnFailure)

### \[1.0.0] - 2024-05-23

#### Added

* Initial implementation


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.frends.com/tasks/tasks/avro/serialize.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
