I am trying to find stream start and stop positions of JSON fragments.
At the moment I am using JsonTextReader which allows me to use the JsonTextReader.Path property which can be checked using a regex for matching. It does have LinePosition and LineNumber properties but these are of course for line-based character positions and not the byte stream positions.
The idea is to have fast lookup of JSON fragments using stream seeking (in practice using a substream that sees a slice of another stream, that's why I need the fragment start and stop positions in the underlying stream).
I have also tried System.Text.Json.JsonDocument which has a great API but unfortunateky reads all bytes into memory.
When fragments are looked up they are mapped into domain objects using System.Text.Json where memory consumption is less of an issue since its just fragments.
It is not directly possible to use JsonSerializer to deserialize the fragments, since custom fragment parsing/object-mapping happens using System.Text.Json.
Also, on .NET Framework 4.8, not .NET Core.