I am using .NET Core 3.1 with System.Text.Json
I am reading JSON from file
var jsonFilename = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "WellKnownConfig.json");
if (System.IO.File.Exists(jsonFilename))
{
var fileContent = System.IO.File.ReadAllText(jsonFilename);
if (!string.IsNullOrWhiteSpace(fileContent))
{
//var o = JsonDocument.Parse(fileContent);
Result = new OkObjectResult(fileContent);
}
else
{
Result = new NoContentResult();
}
}
The problem is it is having whitespaces. anyway, I can remove white spaces without string parsing.
Like some way from System.Text.Json
by loading into some object while using JsonDocument
or JsonSerializer
Also is there some way I can minify this JSON after loading it from file
I have seen some solution for newtonjson