We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm migrating a project from Newtonsoft.Json to System.Text.Json in .NET 5.
Newtonsoft.Json
System.Text.Json
I have class:
abstract class Car { public string Name { get; set; } = "Default Car Name"; } class Tesla : Car { public string TeslaEngineName { get; set; } = "My Tesla Engine"; }
I tried:
var cars = new List<Car> { new Tesla(), new Tesla(), new Tesla() }; var json = JsonSerializer.Serialize(cars); Console.WriteLine(json);
The output is:
[ {"Name":"Default Car Name"}, {"Name":"Default Car Name"}, {"Name":"Default Car Name"} ]
Which lost my property: TeslaEngineName.
TeslaEngineName
So how can I serialize derived an object with all properties?
Thanks!
The text was updated successfully, but these errors were encountered:
#45189
Sorry, something went wrong.
Will be addressed by #45189.
No branches or pull requests
I'm migrating a project from
Newtonsoft.Json
toSystem.Text.Json
in .NET 5.I have class:
I tried:
The output is:
Which lost my property:
TeslaEngineName
.So how can I serialize derived an object with all properties?
Thanks!
The text was updated successfully, but these errors were encountered: