# OrleansJsonSerializer Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.serialization.orleansjsonserializer/)

## Deserialize(Type, Stream) {#deserialize-system-type-system-io-stream-bd67dae5}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.serialization.orleansjsonserializer/methods/deserialize-system-type-system-io-stream-bd67dae5/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Serialization/OrleansJsonSerializer.cs)

```csharp
public object Deserialize(Type expectedType, Stream input)
```

Deserializes an object of the specified expected type from the provided stream.

### Parameters

- `expectedType` (`Type`): The expected type.
- `input` (`Stream`): The input stream.

### Returns

The deserialized object.

## Deserialize(Type, string) {#deserialize-system-type-string-62e928fe}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.serialization.orleansjsonserializer/methods/deserialize-system-type-string-62e928fe/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Serialization/OrleansJsonSerializer.cs)

```csharp
public object Deserialize(Type expectedType, string input)
```

Deserializes an object of the specified expected type from the provided input.

### Parameters

- `expectedType` (`Type`): The expected type.
- `input` (`string`): The input.

### Returns

The deserialized object.

## Serialize(object, Type) {#serialize-object-system-type-a380b7a4}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.serialization.orleansjsonserializer/methods/serialize-object-system-type-a380b7a4/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Serialization/OrleansJsonSerializer.cs#L65)

```csharp
public string Serialize(object item, Type expectedType)
```

Serializes an object to a JSON string.

### Parameters

- `item` (`object`): The object to serialize.
- `expectedType` (`Type`): The type the deserializer should expect.

## Serialize(object, Type, Stream) {#serialize-object-system-type-system-io-stream-25bd0f93}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.serialization.orleansjsonserializer/methods/serialize-object-system-type-system-io-stream-25bd0f93/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Serialization/OrleansJsonSerializer.cs#L75-L79)

```csharp
public void Serialize(object item, Type expectedType, Stream destination)
```

Serializes an object to a stream.

### Parameters

- `item` (`object`): The object to serialize.
- `expectedType` (`Type`): The type the deserializer should expect.
- `destination` (`Stream`): The destination stream.
