HarDocument Class

Represents the root of a HAR (HTTP Archive) document.

public sealed class HarDocument

Constructors

NameDescription
HarDocument()

HarDocument()

HarDocument.cs
public HarDocument()

No documentation is available.

Properties

NameDescription
ExtensionDataGets or sets additional vendor-specific fields.
LogGets or sets the log object containing all HAR data.

ExtensionData

HarDocument.cs

Gets or sets additional vendor-specific fields.

public Dictionary<string, JsonElement>? ExtensionData { get; set; }

Gets or sets the log object containing all HAR data.

public HarLog? Log { get; set; }

Property value

HarLog?

Methods

NameDescription
Parse(Stream)Parses a HAR document from a UTF-8 stream.
Parse(string)Parses a HAR document from a JSON string.
ParseAsync(Stream, CancellationToken)Asynchronously parses a HAR document from a UTF-8 stream.
ToJsonString(bool)Serializes the HAR document to a JSON string.
WriteTo(Stream, bool)Serializes the HAR document to a UTF-8 stream.
WriteToAsync(Stream, bool, CancellationToken)Asynchronously serializes the HAR document to a UTF-8 stream.

Parse overloads

Parse(Stream)

HarDocument.cs

Parses a HAR document from a UTF-8 stream.

public static HarDocument Parse(Stream stream)
Parameters
stream Stream
The stream containing the HAR JSON data.
Returns

HarDocument The parsed HAR document.

Parse(string)

HarDocument.cs

Parses a HAR document from a JSON string.

public static HarDocument Parse(string json)
Parameters
json string
The JSON string to parse.
Returns

HarDocument The parsed HAR document.

ParseAsync(Stream, CancellationToken)

HarDocument.cs

Asynchronously parses a HAR document from a UTF-8 stream.

net10.0

public static Task<HarDocument> ParseAsync(Stream stream, CancellationToken cancellationToken = default)

net11.0

public static Task<HarDocument> ParseAsync(Stream stream, CancellationToken cancellationToken = default)

Parameters

stream Stream
The stream containing the HAR JSON data.
cancellationToken CancellationToken
A cancellation token to observe.

Returns

Task<HarDocument> The parsed HAR document.

ToJsonString(bool)

HarDocument.cs

Serializes the HAR document to a JSON string.

public string ToJsonString(bool indented = false)

Parameters

indented bool
Whether to format the JSON output with indentation.

Returns

string The JSON string representation of the HAR document.

WriteTo(Stream, bool)

HarDocument.cs

Serializes the HAR document to a UTF-8 stream.

public void WriteTo(Stream stream, bool indented = false)

Parameters

stream Stream
The stream to write the JSON data to.
indented bool
Whether to format the JSON output with indentation.

WriteToAsync(Stream, bool, CancellationToken)

HarDocument.cs

Asynchronously serializes the HAR document to a UTF-8 stream.

public Task WriteToAsync(Stream stream, bool indented = false, CancellationToken cancellationToken = default)

Parameters

stream Stream
The stream to write the JSON data to.
indented bool
Whether to format the JSON output with indentation.
cancellationToken CancellationToken
A cancellation token to observe.

Returns

Task