From the course: Advanced .NET: Commands, C# Enhancements, Web Apps, and Libraries
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
JSON updates: Create JsonSerializerContext classes - .NET Tutorial
From the course: Advanced .NET: Commands, C# Enhancements, Web Apps, and Libraries
JSON updates: Create JsonSerializerContext classes
- This is the class that I want to serialize. It's called the food class. It has food name, calories, and category as the properties. So the first step is to create this public class here. And then I create another class called food generation context that drives from JSUN serializer context. And I indicate what type of want to serialize. That's what I'm doing here in line 20. And I also indicate any serialization options here. I want to write indented equal true. And I want to use camel casing or names. So this is called Foods Generation Context. And you notice it's marked as a partial class because the source generator's going to create the rest of the cup. I'm also going to to serialize an eye innumerable of food. So I do the same thing, here I call this one Foods Generation Context and everything else is the same, except for the type where I said, type of IEnumerable food. So that's it. Now let's go up here and…
Contents
-
-
-
-
-
-
-
-
(Locked)
Single file application7m 9s
-
(Locked)
DateTime, TimeOnly, DateOnly2m 26s
-
(Locked)
ArgumentNullException.ThrowIfNull method57s
-
(Locked)
LINQ updates: OrDefault operators1m 17s
-
(Locked)
LINQ updates: Chunk2m 53s
-
(Locked)
LINQ updates: Zip50s
-
(Locked)
Collection updates3m
-
(Locked)
Threading: Parallel.ForEachAsync4m 7s
-
(Locked)
Threading: PeriodicTimer, the problem4m 42s
-
(Locked)
Threading: PeriodicTimer, the solution2m 11s
-
(Locked)
JSON updates: Overview2m 58s
-
(Locked)
JSON updates: Create JsonSerializerContext classes2m 33s
-
(Locked)
JSON updates: Serialize3m 1s
-
(Locked)
JSON updates: Writable DOM2m 26s
-
(Locked)
More .NET library updates5m 50s
-
(Locked)
-
-