Controlling JSON processing
There are many options for taking control of how JSON is processed, as shown in the following list:
- Including and excluding fields.
- Setting a casing policy.
- Selecting a case-sensitivity policy.
- Choosing between compact and prettified whitespace.
Let's see some in action:
- Use your preferred code editor to add a new console app named
WorkingWithJson
to theChapter09
solution/workspace. - In Visual Studio Code, select
WorkingWithJson
as the active OmniSharp project. - In the
WorkingWithJson
project, inProgram.cs
, delete the existing code, import the two main namespaces for working with JSON, and then statically import theSystem.Console
,System.Environment
, andSystem.IO.Path
types, as shown in the following code:using System.Text.Json; // JsonSerializer using System.Text.Json.Serialization; // [JsonInclude] using static System.Console; using static System.Environment; using static System...