You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add JSONPath to the exception thrown by JsonDocument while parsing invalid JSON #29715
In addition, once this is complete, the serializer should re-throw JsonReaderException (as it does today) but now with the Path property pre-pended with the results from JsonReaderException to include the full Path of the serializer + JsonDocument.
Is the idea that the database building routine be in a try/catch where the catch modifies the exception object and then continues the same callstack/dispatch with throw;? Next most obvious alternative: That in the catch it throws a new Exception, wrapping the old one, and the outer one has the path set.
Either of those seems doable; either by making the StackRow value also keep track of the StartObject/StartArray (which would also eliminate the seek-backwards for every EndObject/EndArray at the expense of needing to grow the temporary buffer more often) or changing/overloading FindIndexOfFirstUnsetSizeOrLength to accept a "no later than" parameter. -- The StackRowStack knows how many elements already exist in the array (maybe off-by-one, but the data is there), and for an object property the name is available from the node after StartArray.
It's probably something easy enough for up-for-grabs.
to ParseCore, and making a new Parse with the same signature which just does
privatestaticvoidParse(ReadOnlySpan<byte>utf8JsonSpan,Utf8JsonReaderreader,refMetadataDbdatabase,refStackRowStackstack){try{ParseCore(utf8JsonSpan,reader,refdatabase,refstack);}catch(JsonReaderExceptione){// Using stack, database, and maybe Stack<string> parts, build the pathe.Path=path;}}
Is JsonPath support for querying the JsonDocument/JsonElement structures still being looked at, as this is a major gap for us shifting from Newtonsoft to system.text.json.
Is JsonPath support for querying the JsonDocument/JsonElement structures still being looked at
This issue is specifically about storing the JSON path information as part of the exception whenever the JsonDocument sees an invalid JSON while parsing, and not about full-fledged JsonPath support for querying the JSON data within the JsonDocument. Since this would be a separate feature, please create a separate issue for it. I would imagine the path support (at least for your use case), primarily be for convenience (requiring less code).
changed the title [-]Support JSONPath on JsonDocument[/-][+]Add JSONPath to the exception thrown by JsonDocument while parsing invalid JSON[/+]on Oct 4, 2019
Activity
MarcoRossignoli commentedon Jun 5, 2019
@steveharter is this fixed?Should we close?
ahsonkhan commentedon Jun 11, 2019
cc @bartonjs
bartonjs commentedon Jun 11, 2019
Is the idea that the database building routine be in a try/catch where the catch modifies the exception object and then continues the same callstack/dispatch with
throw;? Next most obvious alternative: That in the catch it throws a new Exception, wrapping the old one, and the outer one has the path set.Either of those seems doable; either by making the StackRow value also keep track of the StartObject/StartArray (which would also eliminate the seek-backwards for every EndObject/EndArray at the expense of needing to grow the temporary buffer more often) or changing/overloading
FindIndexOfFirstUnsetSizeOrLengthto accept a "no later than" parameter. -- The StackRowStack knows how many elements already exist in the array (maybe off-by-one, but the data is there), and for an object property the name is available from the node after StartArray.It's probably something easy enough for up-for-grabs.
I'd do it by renaming
to
ParseCore, and making a new Parse with the same signature which just doesgary-holland commentedon Oct 1, 2019
Hi,
Is JsonPath support for querying the JsonDocument/JsonElement structures still being looked at, as this is a major gap for us shifting from Newtonsoft to system.text.json.
What we need is an equivalent to:
Something like this would be ideal:
Thanks.
ahsonkhan commentedon Oct 4, 2019
This issue is specifically about storing the JSON path information as part of the exception whenever the JsonDocument sees an invalid JSON while parsing, and not about full-fledged JsonPath support for querying the JSON data within the JsonDocument. Since this would be a separate feature, please create a separate issue for it. I would imagine the path support (at least for your use case), primarily be for convenience (requiring less code).
[-]Support JSONPath on JsonDocument[/-][+]Add JSONPath to the exception thrown by JsonDocument while parsing invalid JSON[/+]gary-holland commentedon Oct 4, 2019
Thanks. @ahsonkhan. I've created a new issue dotnet/corefx#41537
layomia commentedon Feb 21, 2020
Triage: action item is to remove this test and close this issue.
runtime/src/libraries/System.Text.Json/tests/Serialization/ExceptionTests.cs
Lines 366 to 380 in d4b06b1
anreton commentedon Mar 29, 2020
It would be great if it was implemented.
For example, there is JsonConverter:
We are trying to deserialize:
and get:
It would be great to get JsonException with the path and line number.