# JsonSerializer

Kind: Class · Namespace: Sansar.Utility · Assembly: Sansar.Script.dll · Script API 47.10.0

<div class="api-meta">
<span class="api-kind api-kind-class" data-pagefind-filter="kind:Class">Class</span>
<span data-pagefind-filter="namespace:Sansar.Utility">Namespace <a href="/scripting/api/sansar.utility"><code>Sansar.Utility</code></a></span>
</div>

<span id="T:Sansar.Utility.JsonSerializer"></span>

Converts objects to and from javascript object notation strings

```csharp
public static class JsonSerializer
```

## Members at a glance

| Kind | Members |
|---|---|
| **Methods** | [Deserialize](#deserialize) · [Serialize](#serialize) |

## Methods

### Deserialize

<div class="api-card" id="deserialize-string-action">
<span id="M:Sansar.Utility.JsonSerializer.Deserialize``1(System.String,System.Action{Sansar.Utility.JsonSerializationData{``0}})"></span>

```csharp signature
public static void Deserialize<T>(
    string value,
    Action<JsonSerializationData<T>> done
)
```

Converts the given string to an object.

| Parameter | Type | Description |
|---|---|---|
| `value` | [string](https://learn.microsoft.com/dotnet/api/system.string) | The string in json notation. |
| `done` | [Action&lt;JsonSerializationData&lt;T&gt;&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | The action to call when the conversion is complete. |

**Type parameters:** `T`: The type to create.

</div>

<div class="api-card" id="deserialize-string-jsonserializeroptions-action">
<span id="M:Sansar.Utility.JsonSerializer.Deserialize``1(System.String,Sansar.Utility.JsonSerializerOptions,System.Action{Sansar.Utility.JsonSerializationData{``0}})"></span>

```csharp signature
public static void Deserialize<T>(
    string value,
    JsonSerializerOptions options,
    Action<JsonSerializationData<T>> done
)
```

Converts the given string to an object.

| Parameter | Type | Description |
|---|---|---|
| `value` | [string](https://learn.microsoft.com/dotnet/api/system.string) | The string in json notation. |
| `options` | [JsonSerializerOptions](/scripting/api/sansar.utility/jsonserializeroptions) | Options to control the deserialization. |
| `done` | [Action&lt;JsonSerializationData&lt;T&gt;&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | The action to call when the conversion is complete. |

**Type parameters:** `T`: The type to create.

</div>

### Serialize

<div class="api-card" id="serialize-t-action">
<span id="M:Sansar.Utility.JsonSerializer.Serialize``1(``0,System.Action{Sansar.Utility.JsonSerializationData{``0}})"></span>

```csharp signature
public static void Serialize<T>(
    T value,
    Action<JsonSerializationData<T>> done
)
```

Converts the given object to a Json string

| Parameter | Type | Description |
|---|---|---|
| `value` | T | The object to be converted |
| `done` | [Action&lt;JsonSerializationData&lt;T&gt;&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | The action to call when the conversion is complete. |

**Type parameters:** `T`: The type of the object to convert. This can usually be inferred.

</div>

<div class="api-card" id="serialize-t-jsonserializeroptions-action">
<span id="M:Sansar.Utility.JsonSerializer.Serialize``1(``0,Sansar.Utility.JsonSerializerOptions,System.Action{Sansar.Utility.JsonSerializationData{``0}})"></span>

```csharp signature
public static void Serialize<T>(
    T value,
    JsonSerializerOptions options,
    Action<JsonSerializationData<T>> done
)
```

Converts the given object to a Json string

| Parameter | Type | Description |
|---|---|---|
| `value` | T | The object to be converted |
| `options` | [JsonSerializerOptions](/scripting/api/sansar.utility/jsonserializeroptions) | Options to control the serialization. |
| `done` | [Action&lt;JsonSerializationData&lt;T&gt;&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | The action to call when the conversion is complete. |

**Type parameters:** `T`: The type of the object to convert. This can usually be inferred.

</div>




<p class="api-generated" data-pagefind-ignore>Generated from the Sansar 47.10.0 client ScriptApi snapshot.</p>