Table of Contents

Class ResourceObjectConverter

Namespace
JsonApiDotNetCore.Serialization.JsonConverters
Assembly
JsonApiDotNetCore.dll

Converts ResourceObject to/from JSON.

[UsedImplicitly(ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature)]
public class ResourceObjectConverter : JsonObjectConverter<ResourceObject>
Inheritance
ResourceObjectConverter
Inherited Members

Constructors

ResourceObjectConverter(IResourceGraph)

public ResourceObjectConverter(IResourceGraph resourceGraph)

Parameters

resourceGraph IResourceGraph

Methods

Read(ref Utf8JsonReader, Type, JsonSerializerOptions)

Resolves the resource type and attributes against the resource graph. Because attribute values in ResourceObject are typed as object, we must lookup and supply the target type to the serializer.

public override ResourceObject Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

Parameters

reader Utf8JsonReader
typeToConvert Type
options JsonSerializerOptions

Returns

ResourceObject

Write(Utf8JsonWriter, ResourceObject, JsonSerializerOptions)

Ensures that attribute values are not wrapped in JsonElements.

public override void Write(Utf8JsonWriter writer, ResourceObject value, JsonSerializerOptions options)

Parameters

writer Utf8JsonWriter
value ResourceObject
options JsonSerializerOptions