-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(serialization)!: migrate from YamlDotnet to System.Text.Json (#125)
- Loading branch information
1 parent
19f62ea
commit a0c6d7f
Showing
63 changed files
with
624 additions
and
1,598 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) The LEGO Group. All rights reserved. | ||
|
||
namespace LEGO.AsyncAPI.Readers | ||
{ | ||
using System; | ||
using System.Globalization; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text.Json.Nodes; | ||
using LEGO.AsyncAPI.Exceptions; | ||
using YamlDotNet.RepresentationModel; | ||
|
||
internal static class JsonHelper | ||
{ | ||
public static string GetScalarValue(this JsonNode node) | ||
{ | ||
var scalarNode = node is JsonValue value ? value : throw new AsyncApiException($"Expected scalar value"); | ||
return Convert.ToString(scalarNode.GetValue<object>(), CultureInfo.InvariantCulture); | ||
} | ||
|
||
public static JsonNode ParseJsonString(string jsonString) | ||
{ | ||
return JsonNode.Parse(jsonString); | ||
var reader = new StringReader(jsonString); | ||
var yamlStream = new YamlStream(); | ||
yamlStream.Load(reader); | ||
|
||
var yamlDocument = yamlStream.Documents.First(); | ||
return yamlDocument.RootNode.ToJsonNode(); | ||
} | ||
} | ||
} |
Oops, something went wrong.