Closed
Description
Given the following payload:
{
"picture": "http://placehold.it/32x32",
"eyeColor": "Brown",
"registered": "2015-05-30T01:50:21 -01:00"
}
And the following models:
public sealed class Model
{
public Color EyeColor { get; set; }
public Uri Picture { get; set; }
public DateTime Registered { get; set; }
}
public enum Color
{
Blue,
Green,
Brown
}
An exception is thrown when attempting to deserialize using:
JsonSerializer.Parse<Model>(
json,
new JsonSerializerOptions
{
IgnoreNullValues = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
WriteIndented = false
});
Exception:
System.Text.Json.JsonException: 'The JSON value could not be converted to System.Uri. Path: $.picture | LineNumber: 1 | BytePositionInLine: 39.'
In fact, it is unable to deserialize any of the three properties and not just the Uri.
This is running against the following:
Version: 3.0.0-preview6-27804-01
Commit: fdf81c6faf
The same payload is deserialized as expected in both UTF8Json and JSON.NET.