/// <summary>
/// Prevents a property from being serialized or deserialized.
/// </summary>
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public sealed class JsonIgnoreAttribute : JsonAttribute
{
/// <summary>| sudo ./build.sh -subsetCategory coreclr -configuration Release | |
| __DistroRid: linux-x64 | |
| __RuntimeId: linux-x64 | |
| Downloading 'https://dot.net/v1/dotnet-install.sh' | |
| Trying to run 'curl https://dot.net/v1/dotnet-install.sh -sSL --retry 10 --create-dirs -o /home/layomia/repos/dotnet_runtime/.dotnet/dotnet-install.sh' for maximum of 5 attempts. | |
| Ran 'curl https://dot.net/v1/dotnet-install.sh -sSL --retry 10 --create-dirs -o /home/layomia/repos/dotnet_runtime/.dotnet/dotnet-install.sh' successfully. | |
| dotnet_install: Warning: Unable to locate zlib. Probable prerequisite missing; install zlib. | |
| dotnet-install: Downloading link: https://dotnetcli.azureedge.net/dotnet/Sdk/5.0.100-preview.3.20168.11/dotnet-sdk-5.0.100-preview.3.20168.11-linux-x64.tar.gz | |
| dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Sdk/5.0.100-preview.3.20168.11/dotnet-sdk-5.0.100-preview.3.20168.11-linux-x64.tar.gz | |
| dotnet-install: Adding to current process PATH: `/home/layomia/repos/dotnet_runtime/.dotnet`. Note: This change will |
JsonSerializer deserializes instances of objects (classes and structs) using public parameterless
constructors. If none is present, and deserialization is attempted, the serializer throws a NotSupportedException
with a message stating that objects without public parameterless constructors, including interfaces and abstract
types, are not supported for deserialization. There is no way to deserialize an instance of an object using a
parameterized constructor.
Deserialize LoginViewModel
| Method | Mean | Error | StdDev | Median | Min | Max | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|---|
| Jil | 492.3 ns | 11.13 ns | 11.43 ns | 488.6 ns | 479.8 ns | 522.1 ns | 0.0629 | - | - | 264 B |
| JSON.NET | 1,288.4 ns | 26.17 ns | 67.55 ns | 1,263.9 ns | 1,209.4 ns | 1,493.6 ns | 0.6618 | - | - | 2776 B |
| Utf8Json | 360.5 ns | 3.07 ns | 2.56 ns | 360.4 ns | 355.4 ns | 365.5 ns | 0.0668 | - | - | 280 B |
| Default | 517.7 ns | 3.63 ns | 3.03 ns | 517.3 ns | 512.5 ns | 522.3 ns | 0.0391 | - | - | 168 B |
| AOT_LoadConverters | 471.8 ns | 9.14 ns | 11.22 ns | 469.3 ns | 452.2 ns | 494.5 ns | 0.0401 | - | - | 168 B |
| AOT_Raw | 402.2 ns | 10.17 ns | 9.51 ns |
| private static void HandleStartObject(JsonSerializerOptions options, ref ReadStack state) | |
| { | |
| Debug.Assert(!state.Current.IsProcessingDictionary()); | |
| if (state.Current.IsProcessingEnumerable()) | |
| { | |
| // A nested object within an enumerable. | |
| Type objType = state.Current.GetElementType(); | |
| state.Push(); | |
| state.Current.Initialize(objType, options); |
| private static void HandleStartDictionary(JsonSerializerOptions options, ref ReadStack state) | |
| { | |
| Debug.Assert(!state.Current.IsProcessingEnumerable()); | |
| JsonPropertyInfo jsonPropertyInfo = state.Current.JsonPropertyInfo; | |
| if (jsonPropertyInfo == null) | |
| { | |
| jsonPropertyInfo = state.Current.JsonClassInfo.CreateRootProperty(options); | |
| } |
Some performance notes.
- There's no significant performance impact on hot path (de)serialization i.e. primitives, objects, and enumerables.
- There's a little (~4.6% avg.) regression for deserializing
Dictionary,IDictionary, andIReadOnlyDictionary. This is due to some necessary if-checks introduced in shared code-paths between non-immutable dicts and immutable dicts. Splitting their code-paths entirely might mitigate this, but is beyond the scope for preview 6. This will be targeted in preview 7. - We might be able to improve the performance of (de)serializing
ImmutableDicitonary,IImmutableDictionary, andImmutableSortedDictionayby using IL emit to generate high performanceCreateRangemethods.
These benchmarks live in the perf repo.
This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.
###Array ####Definition:
- Stores data elements based on an sequential, most commonly 0 based, index.
- Based on tuples from set theory.