JsonContent Class
- Namespace
- Kampute.HttpClient.Json
- Assembly
- Kampute.HttpClient.Json.dll
Definition
Represents HTTP content based on JSON serialized from an object.
public sealed class JsonContent : HttpContent- Inheritance
- object
- HttpContent
- JsonContent
Constructors
JsonContent(object)
Initializes a new instance of the JsonContent class.
public JsonContent(object content)Parameters
contentobject- The object to be serialized into JSON format.
Exceptions
- ArgumentNullException
- Thrown if
contentisnull.
Properties
Options
Gets or sets the JSON serialization options.
public JsonSerializerOptions Options { get; set; }Property Value
- JsonSerializerOptions
- The JSON serialization options, if any.
Methods
SerializeToStreamAsync(Stream, TransportContext)
Serializes the content to a stream asynchronously.
protected override Task SerializeToStreamAsync(Stream stream, TransportContext context)Parameters
streamStream- The target stream.
contextTransportContext- 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
lengthlong- When this method returns, contains the length of the content in bytes.
