-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ChoETL.Yaml has problems with dynamic objects
- Loading branch information
Showing
16 changed files
with
68 additions
and
63 deletions.
There are no files selected for viewing
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
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
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
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
17 changes: 9 additions & 8 deletions
17
src/File.Infrastructure/FileConversions/Converters/JsonToYamlFileConverter.cs
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
20 changes: 11 additions & 9 deletions
20
src/File.Infrastructure/FileConversions/Converters/YamlToJsonFileConverter.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
using ChoETL; | ||
using File.Infrastructure.Abstractions; | ||
using File.Infrastructure.Abstractions; | ||
using File.Infrastructure.Extensions; | ||
using FluentResults; | ||
using System.Text; | ||
using Newtonsoft.Json; | ||
using YamlDotNet.Serialization; | ||
|
||
namespace File.Infrastructure.FileConversions.Converters | ||
{ | ||
internal sealed class YamlToJsonFileConverter : IFileConverter | ||
{ | ||
public Task<Result<string>> Convert(string fileContent, CancellationToken cancellationToken) | ||
{ | ||
using var yamlReader = ChoYamlReader.LoadText(fileContent); | ||
var stringBuilder = new StringBuilder(); | ||
using var yamlWriter = new ChoYamlWriter(stringBuilder); | ||
yamlWriter.Write(yamlReader); | ||
var jsonContent = stringBuilder.ToString(); | ||
return Task.FromResult(jsonContent.OkIfNotNull()); | ||
var deserializer = new Deserializer(); | ||
var yamlObject = deserializer.Deserialize(fileContent); | ||
|
||
var jsonSerializer = new JsonSerializer(); | ||
using var writer = new StringWriter(); | ||
jsonSerializer.Serialize(writer, yamlObject); | ||
|
||
return Task.FromResult(writer.ToString().OkIfNotNull()); | ||
} | ||
} | ||
} |
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
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
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
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
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
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
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
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
2 changes: 1 addition & 1 deletion
2
.../File.Infrastructure.UnitTests/FileConversions/Converters/YamlToJsonFileConverterTests.cs
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
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