# GrainIdJsonConverter Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.grainidjsonconverter/)

## Read(Utf8JsonReader, Type, JsonSerializerOptions) {#read-ref-system-text-json-utf8jsonreader-system-type-system-text-json-jsonserial-7b0377e9}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.grainidjsonconverter/methods/read-ref-system-text-json-utf8jsonreader-system-type-system-text-json-jsonserial-7b0377e9/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core.Abstractions/IDs/GrainId.cs#L211-L222)

```csharp
public override GrainId Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
```

Reads and converts the JSON to type `T`.

### Parameters

- `reader` (`Utf8JsonReader`): The reader.
- `typeToConvert` (`Type`): The type to convert.
- `options` (`JsonSerializerOptions`): An object that specifies serialization options to use.

### Returns

The converted value.

## ReadAsPropertyName(Utf8JsonReader, Type, JsonSerializerOptions) {#readaspropertyname-ref-system-text-json-utf8jsonreader-system-type-system-text-j-398ec5ff}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.grainidjsonconverter/methods/readaspropertyname-ref-system-text-json-utf8jsonreader-system-type-system-text-j-398ec5ff/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core.Abstractions/IDs/GrainId.cs#L227)

```csharp
public override GrainId ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
```

Reads a dictionary key from a JSON property name.

### Parameters

- `reader` (`Utf8JsonReader`): The `System.Text.Json.Utf8JsonReader` to read from.
- `typeToConvert` (`Type`): The type to convert.
- `options` (`JsonSerializerOptions`): The options to use when reading the value.

### Returns

The value that was converted.

## Write(Utf8JsonWriter, GrainId, JsonSerializerOptions) {#write-system-text-json-utf8jsonwriter-orleans-runtime-grainid-system-text-json-j-b83ef7e8}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.grainidjsonconverter/methods/write-system-text-json-utf8jsonwriter-orleans-runtime-grainid-system-text-json-j-b83ef7e8/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core.Abstractions/IDs/GrainId.cs#L231)

```csharp
public override void Write(Utf8JsonWriter writer, GrainId value, JsonSerializerOptions options)
```

Writes a specified value as JSON.

### Parameters

- `writer` (`Utf8JsonWriter`): The writer to write to.
- `value` (`GrainId`): The value to convert to JSON.
- `options` (`JsonSerializerOptions`): An object that specifies serialization options to use.

## WriteAsPropertyName(Utf8JsonWriter, GrainId, JsonSerializerOptions) {#writeaspropertyname-system-text-json-utf8jsonwriter-orleans-runtime-grainid-syst-dc908f02}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.grainidjsonconverter/methods/writeaspropertyname-system-text-json-utf8jsonwriter-orleans-runtime-grainid-syst-dc908f02/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core.Abstractions/IDs/GrainId.cs#L235)

```csharp
public override void WriteAsPropertyName(Utf8JsonWriter writer, GrainId value, JsonSerializerOptions options)
```

Writes a dictionary key as a JSON property name.

### Parameters

- `writer` (`Utf8JsonWriter`): The `System.Text.Json.Utf8JsonWriter` to write to.
- `value` (`GrainId`): The value to convert. The value of `System.Text.Json.Serialization.JsonConverter-1.HandleNull` determines if the converter handles `null` values.
- `options` (`JsonSerializerOptions`): The options to use when writing the value.
