# Use custom serializer

By default, Databrain uses the Newtonsoft Json library to serialize the data to a json file. It is possible though to serialize the data with a custom serializer such as Odin Serializer.&#x20;

Simply use the API methods **GetSerializableData** and **SetSerializedData**.

\
Here's a simple example using Odin Serializer:

```csharp
using OdinSerializer;

// The data library
public DataLibrary data;

public void Save()
{
    // Get the serializable data class from the data library
    var serializableData = data.GetSerializableData();
    
    // Use Odin Serializer to serialize the data
    byte[] bytes = SerializationUtility.SerializeValue(serializableData, DataFormat.Binary);
    // Write to a file
    System.IO.File.WriteAllBytes(System.IO.Path.Combine(Application.persistentDataPath, "saveFile.data"), bytes);
}

public void Load()
{
    // Load the file as bytes
    byte[] bytes = System.IO.File.ReadAllBytes(System.IO.Path.Combine(Application.persistentDataPath, "saveFile.data"));
    
    // Deserialize the data using Odin Serializer
    var serializableData = SerializationUtility.DeserializeValue<DataLibrary.JsonSerializeableClass>(bytes, DataFormat.Binary);
    
    // Set the data back to the data library.
    // This will load the complete data and also calls the OnLoaded event.
    data.SetSerializedData(serializableData );
}
```


---

# 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://giantgrey.gitbook.io/databrain/guides/use-custom-serializer.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.
