projects/json/README.md
All about the new System.Text.Json namespace.
Use JsonSerializer.SerializeAsync to serializer your object to JSON directly to stream.
Use JsonSerializerOptions to control certain aspect of your object serialization.
Json - Serializing Anonymous Type
Create adhoc JSON document using anonymous type and serialize it to stream directly using JsonSerializer.SerializeAsync.
Json - Control serialization using attributes
Use [JsonPropertyName] and [JsonIgnore] to control JSON serialization output.
Json - Serialize a Dictionary of object
A Dictionary<string, object> can be used to generate pretty much any shape of JSON document that you want.
Json - Write a JSON document to the stream directly
Use Utf8JsonWriter to write a JSON document directly to a stream.
Json - Implement a custom naming policy
Create a custom naming policy that generate JSON property names in snake_case.
Benchmark on two different approaches of generating snake_case property names.
Implement a custom type converter. In this example we convert TimeSpan.
Json - Control JsonIgnore behaviour
Demonstrate the three different ways you can control the behaviour of [JsonIgnore] per property.
Implement a custom type coverter for DateTime type for JsonSerializer in the format of JSON date ticks.
Design document for the Writable JSON API
This sample shows how to parse and access number, string and an array values from JSON string.
This sample shows how to parse and access objects from JSON string. We will be using JsonObject as well.
This sample shows how to find a node based on of its value using LINQ.
This sample shows how to find a node based on two of its values (a string and an array) using LINQ.
This sample shows how to find a node based of an absence of a property using LINQ.
In this example we are trying to find a node in an array that has a specific value on its array property.
This sample shows how to construct a JSON document using JsonObject.
This sample shows how to construct a JSON document using JsonArray.
This sample shows how to update properties of a JSON document.
Delete elements in a JSON document
This example shows how to update remove an object property and an element in an array.
This example shows how to add items at the first position of an array and at the last position.
Show how to customize serialization using DefaultJsonTypeInfoResolver.
Customize serialization by writing number as string in JSON for Age values.
In this case we add one extra timestamp property to the serialization process.
This sample shows how to detect the type of a JSON property.
dotnet8