JsonContent Class

Namespace
Kampute.HttpClient.NewtonsoftJson
Assembly
  • Kampute.HttpClient.NewtonsoftJson.dll

Definition

Represents HTTP content based on JSON serialized from an object.
public sealed class JsonContent : HttpContent
Inheritance

Constructors

JsonContent(object)

Initializes a new instance of the JsonContent class.
public JsonContent(object content)

Parameters

content object
The object to be serialized into JSON format.

Exceptions

ArgumentNullException
Thrown if content is null.

Properties

Settings

Gets or sets the JSON serialization settings.
public JsonSerializerSettings Settings { get; set; }

Property Value

JsonSerializerSettings
The JSON serialization settings, if any.

Methods

SerializeToStreamAsync(Stream, TransportContext)

Serializes the content to a stream asynchronously.
protected override Task SerializeToStreamAsync(Stream stream, TransportContext context)

Parameters

stream Stream
The target stream.
context TransportContext
The transport context.

Returns

Task
A task that represents the asynchronous operation.

TryComputeLength(out long)

Attempts to compute the length of the content.
protected override bool TryComputeLength(out long length)

Parameters

length long
When this method returns, contains the length of the content in bytes.

Returns

bool
true if the length could be computed; otherwise, false.