ReqRest
Show / Hide Table of Contents

Class JsonHttpContentSerializer

An HttpContent (de-)serializer which uses the Newtonsoft.Json library for the (de-)serialization process.

Consider using the Default property for accessing a default JsonHttpContentSerializer instance if you don't require any specific JSON serialization settings.

Inheritance
Object
HttpContentSerializer
JsonHttpContentSerializer
Implements
IHttpContentSerializer
IHttpContentDeserializer
Namespace: ReqRest.Serializers.NewtonsoftJson
Assembly: ReqRest.Serializers.NewtonsoftJson.dll
Syntax
public class JsonHttpContentSerializer : HttpContentSerializer, IHttpContentSerializer, IHttpContentDeserializer

Constructors

JsonHttpContentSerializer(Nullable<JsonSerializer>)

Initializes a new instance of the JsonHttpContentSerializer with an optional Newtonsoft.Json.JsonSerializer to be used for the (de-)serialization.

Declaration
public JsonHttpContentSerializer(JsonSerializer? jsonSerializer = default(JsonSerializer? ))
Parameters
Type Name Description
Nullable<Newtonsoft.Json.JsonSerializer> jsonSerializer

The Newtonsoft.Json.JsonSerializer to be used for (de-)serializing the resource objects.

If null, a default Newtonsoft.Json.JsonSerializer instance is used for (de-)serialization. This is an otherwise default Newtonsoft.Json.JsonSerializer which ignores null values during (de-)serialization.

Properties

Default

Gets a default JsonHttpContentSerializer instance which internally uses a default Newtonsoft.Json.JsonSerializer instance.

This is an otherwise default Newtonsoft.Json.JsonSerializer whose Newtonsoft.Json.JsonSerializer.NullValueHandling is set to Newtonsoft.Json.NullValueHandling.Ignore.

Declaration
public static JsonHttpContentSerializer Default { get; }

JsonSerializer

Gets or sets the Newtonsoft.Json.JsonSerializer to be used for (de-)serializing the resource objects. This can be null. If so, a default Newtonsoft.Json.JsonSerializer instance is used for (de-)serialization. This is an otherwise default Newtonsoft.Json.JsonSerializer which ignores null values during (de-)serialization.

Declaration
protected JsonSerializer? JsonSerializer { get; }

Methods

DeserializeCore(HttpContent, Type)

Called by . This method should perform the actual deserialization logic, i.e. it should deserialize an object of the specified contentType from the httpContent.

Declaration
protected override Task<object? > DeserializeCore(HttpContent httpContent, Type resourceType)
Parameters
Type Name Description
HttpContent httpContent

An HttpContent instance from which the content should be serialized.

Type resourceType
Returns
Type Description
Task<Nullable<Object>>

An object of type contentType.

Overrides
HttpContentSerializer.DeserializeCore(HttpContent, Type)

SerializeCore(Nullable<Object>, Encoding)

Called by . This method should perform the actual serialization logic, i.e. it should serialize the specified content into a new HttpContent instance.

Declaration
protected override HttpContent? SerializeCore(object? resource, Encoding encoding)
Parameters
Type Name Description
Nullable<Object> resource
Encoding encoding

An optional encoding to be used by the serializer if it serializes the content to an HttpContent which requires one.

Returns
Type Description
Nullable<HttpContent>

A new HttpContent instance which holds the serialized content or null.

Overrides
HttpContentSerializer.SerializeCore(Nullable<Object>, Encoding)

Implements

IHttpContentSerializer
IHttpContentDeserializer
Back to top Copyright © 2019 ReqRest - Generated with DocFX - Material Theme made by Oscar Vásquez - Impressum (Imprint)