System.Text.Json Retrieve Line / Column Numbers #53788
Labels
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
area-System.Text.Json
needs-further-triage
Issue has been initially triaged, but needs deeper consideration or reconsideration
Milestone
Apologies if the solution to this already exists, but upon initial inspection of using System.Text.Json, I cannot seem to find it. Please kindly point me in the correct direction.
I would like to be able to get line and column numbers reliably from either utf8jsonreader and [optionally / additionally] JsonDocument type APIs. Looking at Newtonsoft, it seems like the JsonTextReader supports these properties on the reader. Poking around some other issues, it seems like LineNumber was supposed to be exposed in an issue in 2019, but got left in some sort of limbo.
Using utf8jsonreader directly allows me to parse json documents in complex scenarios not supported by higher level APIs. However, this also means I would like to direct the user to the exact line and column for information or errors.
Before anybody jumps in and says that JsonException is what I am looking for (which contains line / columns), no it is not. A json document can have a perfectly valid parse-able state, but an invalid logical state based on complex logic. That complex logic is what a schema / reader can't really implement easily.
It is a shame that these properties are not exposed right now, because as I understand it, the values already exist down inside the implementation. I will have to use newtonsoft at least until these are exposed.
The text was updated successfully, but these errors were encountered: