Created
March 16, 2024 13:31
-
-
Save renatogroffe/f53dcfbfc4c703fa5f7b04ef4bbdee53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using ConsoleAppIndentationOptions.Models; | |
using System.Runtime.InteropServices; | |
using System.Text.Json; | |
Console.WriteLine("***** Testes com .NET 9 | Indentation options *****"); | |
Console.WriteLine($"Versao do .NET em uso: {RuntimeInformation | |
.FrameworkDescription} - Ambiente: {Environment.MachineName} - Kernel: {Environment | |
.OSVersion.VersionString}"); | |
var localidades = new Localidade[] | |
{ | |
new () { Id = 1, NomeCidade = "Sao Paulo", NomePais = "Brasil", NomeContinente = "America do Sul" }, | |
new () { Id = 2, NomeCidade = "Roma", NomePais = "Italia", NomeContinente = "Europa" } | |
}; | |
var options = new JsonSerializerOptions | |
{ | |
WriteIndented = true, | |
IndentCharacter = '\t', | |
IndentSize = 1 | |
}; | |
Console.WriteLine(); | |
Console.WriteLine("*** Resultados da serializacao ***"); | |
foreach (var localidade in localidades) | |
{ | |
Console.WriteLine(); | |
Console.WriteLine(JsonSerializer.Serialize(localidade, options)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment