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.
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 |
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 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 |
Overrides
SerializeCore(Nullable<Object>, Encoding)
Called by 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 |
Returns
Type | Description |
---|---|
Nullable<HttpContent> | A new HttpContent instance which holds the serialized |