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
- 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
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
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.
