Skip to content

Commit f9b43df

Browse files
committed
💾 Feat(SyncCodes): Use static json serializer options
1 parent 05b02cc commit f9b43df

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

‎Utils/SyncCodes/FileItem.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Security.Cryptography;
22
using System.Text;
3+
using System.Text.Json.Serialization;
34

45
namespace SyncCodes;
56

@@ -9,7 +10,7 @@ public class FileItem
910

1011
public string Hash { get; }
1112

12-
public bool FileLoaded { get; set; }
13+
[JsonIgnore] public bool FileLoaded { get; set; }
1314

1415
public FileItem(string path)
1516
{

‎Utils/SyncCodes/Program.cs

+10-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
var builder = WebApplication.CreateBuilder(args);
1212
var app = builder.Build();
1313

14+
var jsonSerializerOptions = new JsonSerializerOptions()
15+
{
16+
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
17+
WriteIndented = true,
18+
};
19+
1420
Parser.Default.ParseArguments<CommandLineOptions>(args)
1521
.WithParsed(options =>
1622
{
@@ -121,7 +127,8 @@ void RunClient(Context context)
121127
}
122128

123129
var catalog = JsonSerializer.Deserialize<List<FileItem>>(
124-
await catalogResponse.Content.ReadAsStringAsync()
130+
await catalogResponse.Content.ReadAsStringAsync(),
131+
jsonSerializerOptions
125132
)!;
126133

127134
var localCatalog = context.GetFiles();
@@ -142,8 +149,8 @@ await catalogResponse.Content.ReadAsStringAsync()
142149
// .Select(c => new { Original = c.Original, Difference = c.New })
143150
// ;
144151

145-
app.Logger.LogInformation("Need to fetch: {json}", JsonSerializer.Serialize(needToFetch));
146-
app.Logger.LogInformation("Need to delete:: {json}", JsonSerializer.Serialize(needToDelete));
152+
app.Logger.LogInformation("Need to fetch: {json}", JsonSerializer.Serialize(needToFetch, jsonSerializerOptions));
153+
app.Logger.LogInformation("Need to delete:: {json}", JsonSerializer.Serialize(needToDelete, jsonSerializerOptions));
147154
// app.Logger.LogDebug("Need to update: {json}", JsonSerializer.Serialize(needToUpdate));
148155
};
149156
timer.Start();

0 commit comments

Comments
 (0)