WALTER | Workable Algorithms for Location-aware Transmission, Encryption Response

JsonStreamReader<(Of <(<'T>)>)> Class

The class is used for reading JSON data from a stream, with error handling mechanisms to capture any exceptions during the deserialization process.

Namespace:  Walter
Assembly:  Walter (in Walter.dll)

Syntax


public sealed class JsonStreamReader<T>

Type Parameters

T
Type to deserialize

Remarks


This instance doesn't own the stream and therefore will not free the stream

Examples


process a file row by row so you do not have to have the whole file in memory while processing it.
Read a file from disk
using var stream = File.OpenRead("AppData\\LinkedIn.json");
var sr = new Walter.JsonStreamReader<TCPIPNetwork>(stream, TCPIPNetworkJsonContext.Default.TCPIPNetwork);
int i = 0;
var items = new List<TCPIPNetwork>();
await foreach (TCPIPNetwork item in sr.ReadAsync())
{
    i++;
    items.Add(item);
    if (sr.Errors.Count > 0)
    {
        _logger.LogError(sr.Errors[^1], "File line {line}, failed so entry {i} is skipped as it failed due to {error}", sr.Errors[^1].LineNumber, i + 1, sr.Errors[^1].Message);
    }
}

Inheritance Hierarchy


Object
  Walter..::..JsonStreamReader<(Of <(<'T>)>)>