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
Copy file name to clipboardExpand all lines: README.md
+9-6Lines changed: 9 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,9 +23,15 @@ Make sure you have the appropriate .NET target framework installed. This package
23
23
24
24
## Usage
25
25
26
-
Examples of how to serialize and deserialize models with custom date formats using `JsonDateTimeConverter` and `JsonDateTimeFormatConverter`. Note the differences when using source generators with `System.Text.Json`.
26
+
Examples of how to serialize and deserialize models with custom date formats using `JsonDateTimeConverter`attribute and `JsonDateTimeFormatConverter` converter.
27
27
28
-
### Using reflection based with `JsonDateTimeConverter`
28
+
**Note:** The `JsonDateTimeConverter` attribute does not support `System.Text.Json` source generators. Using this attribute with `JsonSerializerContext` results in **SYSLIB1223**: "Attributes deriving from `JsonConverterAttribute` are not supported by the source generator."
29
+
30
+
In such cases, use the `JsonDateTimeFormatConverter`, which also works with reflection-based serialization and deserialization. The `JsonDateTimeConverter` attribute is simply less verbose and more readable than the `JsonDateTimeFormatConverter`.
31
+
32
+
### Using reflection based only with `JsonDateTimeConverter`
33
+
34
+
This will work only with reflection-based serialization and deserialization.
29
35
30
36
```csharp
31
37
publicclassMyModel
@@ -59,13 +65,10 @@ public class Program
59
65
}
60
66
```
61
67
62
-
**Note:**`JsonDateTimeConverter` does not support `System.Text.Json` source generators. Using this converter with `JsonSerializerContext` results in **SYSLIB1223**: "Attributes deriving from `JsonConverterAttribute` are not supported by the source generator." For such cases, use `JsonDateTimeFormatConverter`.
63
-
64
68
### Using Source Generators with `JsonDateTimeFormatConverter`
65
69
66
-
To work with `System.Text.Json` source generators, use `JsonDateTimeFormatConverter` instead of `JsonDateTimeConverterAttribute`.
70
+
To work with `System.Text.Json` source generators, use `JsonDateTimeFormatConverter` instead of `JsonDateTimeConverterAttribute`. This can also work with reflection-based serialization and deserialization.
0 commit comments