-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
dotnet/corefx
#37938Labels
area-System.Text.JsonblockingMarks issues that we want to fast track in order to unblock other important workMarks issues that we want to fast track in order to unblock other important work
Milestone
Description
This wasn't correctly captured as part of #28960, but it would be way more useful for JsonException.Path to be Json Path. This is similar to the way Newtonsoft.Json reports it's deserialization errors and is a bit more useful to identity what is problematic. Consider:
var badData = "{ \"SubModel\": [{ \"Id\": false }] }";
try
{
// JsonConvert.DeserializeObject<TestModel>(badData);
System.Text.Json.Serialization.JsonSerializer.Parse<TestModel>(badData);
}
catch (JsonException ex)
{
System.Console.WriteLine(ex.Path);
}
public class TestModel
{
public List<TestSubModel> SubModel { get; set; }
}
public class TestSubModel
{
public int Id { get; set; }
}
Output: [console1.TestModel].SubModel.IdThe same data through Json.NET produces SubModel[0].Id which tells which segment of the Json payload is problematic.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-System.Text.JsonblockingMarks issues that we want to fast track in order to unblock other important workMarks issues that we want to fast track in order to unblock other important work